sentry-javascript
sentry-javascript copied to clipboard
Support React Server Components
We need to investigate how well our tracing plays with the `reactRouterRSC()` vite plugin. This will include adding a e2e test scenario for this case.
--> Investigation Results
Current Support
- Framework Mode with RSC cannot be instrumented right now
- Non-Framework Modes with RSC could be instrumented with
reactRouterTracingIntegrationfrom@sentry/react-routerbut our package requires a peer dependency for@react-router/nodewhich is not needed in RSC (so you need to force-install the packages with the missing peer dep). And in non-framework mode, imports should ideally happen from@sentry/react- not@sentry/react-router
Instrumentation Overview
| Framework | Non-Framework | |
|---|---|---|
| non-RSC | Sentry instruments <HydratedRouter> in entry file (accessed through reveal) |
Sentry instruments createBrowserRouter, <BrowserRouter> etc. |
| RSC | reveal command does not work (yet) - we need access to the entry for instrumenting |
Sentry could instrument <RSCHydratedRouter> from custom entry file (this does not need to be revealed - just added as a Rollup entry) |
Instrumentation Ideas for RSC
Framework
In Framework Mode, we still would need access to the entry file - so we'll need to wait until React Router implements that
Non-Framework
In Data and Declarative Mode we could add an export to @sentry/react which would instrument the RSCHydratedRouter (similar to how reactRouterTracingIntegration from @sentry/react-router instruments the HydratedRouter in Framework Mode).