Description
We would like to trace page loads for the Next.js app router. This would involve somehow passing trace data for Next.js app router SSR to the client for the initial page load.
Currently, we are blocked here by React/Next.js because there is no real way to transparently transfer trace data to the client.
Update (Jan 23, 2024)
We have identified a way to pass trace data from Server Components to the client for page loads. It involves using the useServerInsertedHTML
hook. One thing that is important to know up-front is that this hook can only be used in client components ("use client"
).
In an ideal world, the implementation would look as follows:
We automatically wrap all of the user's server components and make their server components render a client component which returns null
(so we're not actually putting anything in the users page) but are calling userServerInsertedHTML
inside to render <meta />
tags containing sentry-trace
and baggage
data. The <meta />
tag data can then be picked up by the browser SDK to continue the trace.
What blocks us?
- We need to remove the Sentry SDK from the externalized packages list in Next.js itself: It is preventing us from having client-components in the SDK.
Metadata
Metadata
Assignees
Type
Projects
Status