Replies: 6 comments 2 replies
-
Random additional input here: It would be crucial to have something similar to the |
Beta Was this translation helpful? Give feedback.
-
Also interested in sending otel traces from client side. Would be nice in Next.js did that as adding tracing to the frontend code is currently complicated:
Having end-to-end traces could nice |
Beta Was this translation helpful? Give feedback.
-
Another use-case; Initializing Grafana Faro |
Beta Was this translation helpful? Give feedback.
-
Look what we have here; #76916 👀 |
Beta Was this translation helpful? Give feedback.
-
Hello, thank you for adding the clientInstrumentationHook feature :) I recently upgraded my product to version 15.3 and noticed that clientInstrumentationHook is still listed under ExperimentalConfig. Also, may I ask another question? |
Beta Was this translation helpful? Give feedback.
-
Thanks for the detailed write-up — I totally agree that having first-class support for client-side instrumentation in instrumentation.ts would simplify things a lot, especially for cross-environment error tracking setups. At the moment, like you said, most workarounds rely on bundler-level injection or wrapping entry points with tools like Sentry or LogRocket. While they work, they often lead to fragile setups and extra maintenance overhead. In my case, I’ve been experimenting with something like this: Ideally, Next.js could expose something like: Really interested in what the core team thinks here — seems like a great DX improvement. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Allow to register client-only code in
instrumentation.ts
.Background
instrumentation.ts
is currently available for code that executes in Node.js and Edge. However, as far as I know, there is currently no equivalent that is called for the client side.Error-tracking libraries like Sentry currently enable client-side instrumentation, by wrapping each client-side entry point and injecting a custom script into the build.
While this works, I'd argue it's somewhat brittle and also requires quite some custom logic to work. Instead, I'd find it very helpful if Next.js would expose a built-in way that covers this.
My particular use case is adapting the error handling capabilities of
next-intl
to register a global error handler that is automatically called in all environments if registered ininstrumentation.ts
./cc @lforst in case you're interested in this too
Related: #57563
Proposal
Beta Was this translation helpful? Give feedback.
All reactions