Skip to content

Latest commit

 

History

History
36 lines (28 loc) · 1.03 KB

clientInstrumentationHook.mdx

File metadata and controls

36 lines (28 loc) · 1.03 KB
title description version
clientInstrumentationHook
Enable client-side instrumentation.
experimental

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.
import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
  experimental: {
    clientInstrumentationHook: true,
  },
}

export default nextConfig
/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    clientInstrumentationHook: true,
  },
}

module.exports = nextConfig