Skip to content

doc: diff between instrumentation vs instrumentation-client #77143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,33 @@ const nextConfig = {

module.exports = nextConfig
```

## Example

Unlike server-side [instrumentation](/docs/app/building-your-application/optimizing/instrumentation), `instrumentation-client.ts` does not need to export a `register` function. You can write your synchronous code directly in the file:

```ts filename="instrumentation-client.ts" switcher
// No need to export a register function
// This code runs synchronously before hydration
console.log('Client instrumentation initialized')
// Set up performance monitoring
performance.mark('app-init')
// Set up error tracking
window.addEventListener('error', (event) => {
console.error('Captured in instrumentation:', event.error)
// Send to your error tracking service
})
```

```js filename="instrumentation-client.js" switcher
// No need to export a register function
// This code runs synchronously before hydration
console.log('Client instrumentation initialized')
// Set up performance monitoring
performance.mark('app-init')
// Set up error tracking
window.addEventListener('error', (event) => {
console.error('Captured in instrumentation:', event.error)
// Send to your error tracking service
})
```
Loading