Skip to content
Discussion options

You must be logged in to vote

In react-server there are no global frontend or backend hooks for injecting arbitrary code into every page.

On the client side, the intended solution is a top-level Client Component that is mounted once (for example in a root layout or app shell). That's the right place to initialize client-side tooling like Sentry once React is running.

If you specifically need code to run before hydration, that cannot be done via a Client Component at all. At that point you're no longer in React, you're operating at the HTML level. With the file-system router, this is supported by injecting a plain <script> tag directly from a layout. Since that script is emitted into the HTML output, it will execute be…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by aheissenberger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants