Next.js
The Sophonz Next.js SDK gives App Router apps one config for browser and server monitoring — SophonzProvider on the client, register() on the server, sharing a single trace.
@sophonz/nextjs wires up both halves of a Next.js app from one config: @sophonz/browser-sdk on the client and @sophonz/node-sdk on the server. Because both read the same SophonzNextConfig, a page's browser span and the Route Handler that served it land on the same trace.
When to use it
- App Router apps that want browser and server telemetry joined into a single trace, from one config instead of two.
- Projects that would otherwise wire up
@sophonz/browser-sdkand@sophonz/node-sdkby hand and keep their app name and key in sync manually. - If you only need one side — or you're on the Pages Router, or a non-Next Node server — use the Web SDK or Node.js SDK directly instead.
What you get
SophonzProvider— a Client Component you mount once inapp/layout.tsx. It initializes@sophonz/browser-sdkon mount, dynamically imported so it costs nothing until after hydration.register()— a server entry point wired throughinstrumentation.ts. It starts@sophonz/node-sdkbefore any request is handled, so auto-instrumentation can patch modules in time. It no-ops on the Edge runtime.- Shared config resolution — both halves call the same
resolveConfig(), soappName,appVersion,appKey,project, anddeploymentEnvironmentcome from one set ofNEXT_PUBLIC_SOPHONZ_*environment variables, or the same config object if you configure in code. - A joined trace — the browser attaches
traceparentto same-origin requests by default, so a page load and the API route it calls show up on one trace.
How it works
- Client —
SophonzProviderresolvesSophonzNextConfigagainst the environment and dynamically imports@sophonz/browser-sdkon mount. - Server —
register(), called once per server process frominstrumentation.ts, resolves the same config, points the server SDK's OTLP endpoints atcollectorUrl, and calls@sophonz/node-sdk'sinitSDK(). - Both sides apply Sophonz-recommended defaults on top: the server turns on
betaMode(needed forsetTraceAttributes()) and disables its startup banner; the browser disables Intercom-presence polling.
Next steps
- Installation — install the package and wire up both halves.
- Configuration — the full
SophonzNextConfigoption reference.