name | doc_link | support_level | type |
---|---|---|---|
Next.js |
production |
framework |
Configure your app automatically with Sentry wizard.
npx @sentry/wizard -i nextjs
Sentry wizard will automatically patch your application:
- create
sentry.client.config.js
andsentry.server.config.js
with the defaultSentry.init
. - create
next.config.js
with the default configuration. - create
sentry.properties
with configuration for sentry-cli (which is used when automatically uploading source maps).
You can also configure it manually.
Configure the Sentry initialization:
Install Sentry’s Next.js SDK using either yarn
or npm
:
yarn add @sentry/nextjs
# or
npm install --save @sentry/nextjs
Sentry.init({
dsn: '___PUBLIC_DSN___',
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,
});
The above configuration has automatic error tracking with source maps for both JavaScript and TypeScript. We recommend adjusting tracesSampleRate
in production, see Sampling.
Then create an intentional error, so you can test that everything is working from your development environment. For example, a button whose onClick
handler throws an error:
return <button onClick={() => methodDoesNotExist()}>Break the world</button>;
If you're new to Sentry, use the email alert to access your account and complete a product tour.
If you're an existing user and have disabled alerts, you won't receive this email.