clientInstrumentationHook
This feature is currently experimental and subject to change, it's not recommended for production. Try it out and share your feedback on GitHub.
Usage
When enabled, Next.js searches for an instrumentation-client.ts
file at the project root and executes it synchronously before hydration. This file is bundled into the initial JavaScript chunk, allowing you to run analytics or monitoring before any other code executes. The code in this file runs exclusively on the client side and is not executed during server-side rendering (SSR).
Good to know:
- Client instrumentation increases bundle size and execution time, so keep it minimal to avoid delaying interactivity.
next.config.ts
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
experimental: {
clientInstrumentationHook: true,
},
}
export default nextConfig
Was this helpful?