Nuxt

Learn how to set up and configure Sentry in your Nuxt application using the installation wizard, capture your first errors, and view them in Sentry.

You need:

  • A Sentry account and project
  • Your application up and running
  • Nuxt version 3.7.0 or above (3.14.0+ recommended)
Are you using Nuxt version < 3.14.0?

Add the following overrides:

package.json
Copied
"overrides": {
  "ofetch": "^1.4.0",
  "@vercel/nft": "^0.27.4"
}

Run the Sentry init command in your project directory to automatically configure Sentry in your Nuxt application.

The command guides you through setup and asks which optional Sentry features you want to enable beyond error monitoring.

Copied
npx sentry@latest init
How does sentry init work?

The sentry init command is AI-powered. It analyzes your project and generates a tailored integration, rather than applying a fixed template. Here's what it does:

  • Analyzes your project — reads project files and manifests to understand your Nuxt app structure, including monorepos. It also respects AI instruction files such as CLAUDE.md, AGENTS.md, and .cursorrules.
  • Detects your framework — identifies Nuxt and selects the @sentry/nuxt SDK.
  • Fetches official Sentry docs — uses the current Sentry documentation as the source of truth when generating integration code.
  • Installs dependencies — adds @sentry/nuxt using your project's package manager.
  • Creates and modifies files — sets up client-side and server-side initialization, Nuxt module configuration, and other selected features based on your project structure.
  • Verifies the integration — re-reads modified files after writing to confirm Sentry was integrated.

For full details on what each file does, see the Manual Setup guide.

Prefer the existing Nuxt wizard?

If you don't want to use the experimental AI-powered flow, run the framework-specific installation wizard instead:

Copied
npx @sentry/wizard@latest -i nuxt

To configure Sentry manually, follow the Manual Setup guide.

You can prevent ad blockers from blocking Sentry events using tunneling. Use the tunnel option in Sentry.init to add an API endpoint in your application that forwards Sentry events to Sentry servers.

This will send all events to the tunnel endpoint. However, the events need to be parsed and redirected to Sentry, so you'll need to do additional configuration on the server. You can find a detailed explanation on how to do this on our Troubleshooting page.

Copied
Sentry.init({
  dsn: "___PUBLIC_DSN___",
tunnel: "/tunnel",
});

The sentry init command checks the integration files it creates or modifies before it finishes. To confirm runtime events are reaching Sentry, start your Nuxt app, exercise the parts of your app that should send events, and then check your Sentry project.

If you used the Nuxt installation wizard instead, you can also verify your setup with the example page or component it creates.

The wizard created an example component instead of a page.

The wizard creates a SentryErrorButton component when it fails to add an example page to your project. This usually happens if you don't have a app.vue file or if that file does not contain the NuxtPage component. To verify your setup, follow these steps before continuing with the next section, "View Captured Data in Sentry":

  1. Add the SentryErrorButton component to a page and open it in your browser. For most Nuxt applications, this will be at localhost.
  2. Click the "Throw Sample Error" button, which triggers an error and starts a performance trace on the client side.

To test the server side as well, refer to the "Verify" section in the Manual setup guide.

To test Sentry, you can run your Nuxt application in either production or development mode. We recommend testing in production mode as it most closely resembles your deployed application's environment.

After building with nuxi build, run your project and make sure to load Sentry on the server side by explicitly adding it via --import (read more about this flag in Installation Methods).

Copied
# Start your app after building your project with `nuxi build`
node --import ./.output/server/sentry.server.config.mjs .output/server/index.mjs

The server config file is generated in the .nuxt directory the first time you run nuxt dev. If you delete your .nuxt directory, you'll need to run nuxt dev once without the NODE_OPTIONS variable to regenerate it.

If you only want to use Sentry on the client-side or only need basic error monitoring on the server side, you can omit the --import flag when running your application.

Copied
# Run the dev server with the --import flag after running `nuxt dev` once (without the flag)
NODE_OPTIONS='--import ./.nuxt/dev/sentry.server.config.mjs' nuxt dev

If you used the Nuxt installation wizard, after building and running your project:

  1. Open the example page /sentry-example-page in your browser. For most Nuxt applications, this will be at localhost.
  2. Click the "Throw sample error" button. This triggers two errors:
    • a frontend error
    • an error within the API route

Sentry captures both of these errors for you. Additionally, the button click starts a performance trace to measure the time it takes for the API request to complete.

Now, head over to your project on Sentry.io to view the collected data (it takes a couple of moments for the data to appear).

Need help locating the captured errors in your Sentry project?
  • Open the Issues page and select an error from the issues list to view the full details and context of this error. For more details, see the Issue Details documentation.
  • Open the Traces page and select a trace to reveal more information about each span, its duration, and any errors. For an interactive UI walkthrough, click here.
  • Open the Replays page and select an entry from the list to get a detailed view where you can replay the interaction and get more information to help you troubleshoot.
  • Open the Logs page and filter by service, environment, or search keywords to view log entries from your application. For an interactive UI walkthrough, click here.
  • Open the User Feedback page and click on individual feedback to see more details all in one view. For more information, click here.

At this point, you should have integrated Sentry into your Nuxt application and should already be sending error and performance data to your Sentry project.

Now's a good time to customize your setup and look into more advanced topics. Our next recommended steps for you are:

Are you having problems setting up the SDK?
Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").