#Sentry is possible install sentry on next js v 12.3.5
5 messages · Page 1 of 1 (latest)
Hi @somber mica. I'm happy to dig into this for you! I'll check my internal sources for answers to your question! :wave:
Yes, it's possible to install Sentry on Next.js v12.3.5, but you'll need to use an older version of the Sentry SDK. According to the knowledge sources, Next.js v12 is supported in Sentry's v7 SDK, but not in the latest v8 SDK which requires Next.js 13.2.0 or higher.
As mentioned by a Sentry team member in a GitHub issue:
Next.js v12 is still supported in our v7 SDK, but keep in mind that this version of the SDK will only continue to receive critical bugfixes until end of 2024.
JavaScript SDK GitHub Issue
Here's how to set up Sentry with Next.js v12.3.5:
- Install the v7 SDK:
npm install --save @sentry/nextjs@7.x
- Configure your Next.js application by updating your
next.config.js:
const { withSentryConfig } = require("@sentry/nextjs");
const nextConfig = {
// Your existing Next.js configuration
reactStrictMode: true,
};
const moduleExports = nextConfig;
const sentryWebpackPluginOptions = {
// Additional config options for the Sentry Webpack plugin
silent: true, // Suppresses all logs
};
// Make sure adding Sentry options is the last code to run before exporting
module.exports = withSentryConfig(moduleExports, sentryWebpackPluginOptions);
- Create the following configuration files in your project root:
For client-side (sentry.client.config.js):
import * as Sentry from '@sentry/nextjs';
Sentry.init({
dsn: 'YOUR_DSN_HERE',
tracesSampleRate: 1.0,
// Optional: configure Session Replay
integrations: [Sentry.replayIntegration()],
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
});
For server-side (sentry.server.config.js):
import * as Sentry from '@sentry/nextjs';
Sentry.init({
dsn: 'YOUR_DSN_HERE',
tracesSampleRate: 1.0,
});
Remember to replace 'YOUR_DSN_HERE' with your actual Sentry DSN, which you can find in your Sentry project settings.
Note that while this setup will work with Next.js v12.3.5, you should consider upgrading to a newer version of Next.js in the future, as the v7 SDK will only receive critical bugfixes until the end of 2024.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
@somber mica Our robots are still learning and improving, please let us know if this response was correct by reacting below.