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.

We've released v8 of the JavaScript SDKs. If you're using version 7.x, we recommend upgrading to the latest version. Check out the Migration docs to learn how to make the switch.

Don't have a Sentry account? Sign up for Sentry for free, 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:

Copied
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 and entry.server.tsx (if they don't already exist).
  • add the default Sentry.init() for the client in entry.client.tsx and the server in entry.server.tsx.
  • create .sentryclirc with an auth token to upload source maps (this file is automatically added to .gitignore).
  • adjust your build script in package.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
Copied
<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
Copied
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.

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").