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.
This SDK is currently in beta. Beta features are still in progress and may have bugs. Please reach out on GitHub if you have any feedback or concerns.
You need:
- A Sentry account and project
- Your application up and running
- Nuxt version
3.7.0
or above (3.14.0
+ recommended)
To install Sentry using the installation wizard, run the following command within your project:
npx @sentry/wizard@latest -i nuxt
The wizard then guides you through the setup process, asking you to enable additional (optional) Sentry features for your application beyond error monitoring.
This guide assumes that you enable all features and allow the wizard to create an example page or component. You can add or remove features at any time, but setting them up now will save you the effort of configuring them manually later.
If you haven't tested your Sentry configuration yet, let's do it now. You can confirm that Sentry is working properly and sending data to your Sentry project by using the example page created by the installation wizard.
To test Sentry on the server side, you first need to build your project since Sentry's server-side monitoring doesn't work in development mode.
Then run your project and make sure to load Sentry on the server side by explicitly adding it via --import
:
# Start your app after building your project with `nuxi build`
node --import ./.output/server/sentry.server.config.mjs .output/server/index.mjs
After building and running your project:
- Open the example page
/sentry-example-page
in your browser. For most Nuxt applications, this will be at localhost. - 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).
Important
Errors triggered from within your browser's developer tools (like the browser console) are sandboxed, so they will not trigger Sentry's error monitoring.
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:
- Learn how to manually capture errors
- Continue to customize your configuration
- Get familiar with Sentry's product features like tracing, insights, and alerts
- Learn how to track your Vue components or your Pinia store
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").