Remix
Sentry's Remix SDK enables automatic reporting of errors and exceptions, as well as the performance metrics for both client and server side operations.
Sentry's Remix SDK enables automatic reporting of errors and exceptions, as well as the performance metrics for both client and server side operations.
Sentry's Remix SDK relies on our React SDK for the frontend and Node SDK for the backend. That means all features available in those SDKs are also available in this SDK.
Non-Node Support
Sentry's Remix SDK does not officially support adapters that use non-Node runtimes, such as Cloudflare Workers.
If you're seeing deprecation warnings in your code, please note that we're currently working on version 8 of the JavaScript SDKs. In v8, some methods and properties will be removed or renamed. Check out the Migration docs and learn how to update your code to be compatible with v8.
Don't already have an account and Sentry project established? Head over to sentry.io, then return to this page.
Sentry captures data by using an SDK within your application’s runtime.
We recommend installing the SDK through our installation wizard:
npx @sentry/wizard@latest -i remix
The wizard will prompt you to log in to Sentry. It will then automatically do the following steps for you:
- create two files in the root directory of your project,
entry.client.tsx
andentry.server.tsx
(if they don't already exist). - add the default
Sentry.init()
for the client inentry.client.tsx
and the server inentry.server.tsx
. - create
.sentryclirc
with an auth token to upload source maps (this file is automatically added to.gitignore
). - adjust your
build
script inpackage.json
to automatically upload source maps to Sentry when you build your application. - add an example page to your app to verify your Sentry setup
If you use Remix future flags, the wizard will instrument your application accordingly to support Remix v2 features.
After the wizard setup is completed, the SDK will automatically capture unhandled errors, and monitor performance. You can also manually capture errors.
If the wizard setup isn't working for you, you can set up the SDK manually.
Configuration should happen as early as possible in your application's lifecycle.
To complete your configuration, add options to your Sentry.init()
calls. Here, you'll also be able to set context data, which includes data about the user, tags, or even arbitrary data, all of which will be added to every event sent to Sentry.
By default, Remix will minify your JavaScript and CSS files in production. This makes it difficult to debug errors in production. To make debugging easier, you can generate source maps and upload them to Sentry.
Depending on your build setup, you can either use Sentry's Vite plugin or sentry-upload-sourcemaps
script to upload sourcemaps.
Please refer to the Sourcemaps Documentation, for more information.
For more advanced configuration, you can use sentry-cli
directly to upload sourcemaps.
This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.
routes/error.tsx
<button
type="button"
onClick={() => {
throw new Error("Sentry Frontend Error");
}}
>
Throw error
</button>;
This snippet adds a button that throws an error in a component or page.
Errors triggered from within Browser DevTools are sandboxed, so will not trigger an error handler. Place the snippet directly in your code instead.
Then, throw an error in a loader
or action
.
routes/error.tsx
export const action: ActionFunction = async ({ request }) => {
throw new Error("Sentry Error");
};
Learn more about manually capturing an error or message in our Usage documentation.
To view and resolve the recorded error, log into sentry.io and open your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.
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").