Next.js — Configuration
Configure the client provider (SignalNextProvider) and the server client (createSignalServer). Client options are the same browser SDK options as in the React configuration.
SignalNextProvider (client)
createSignalServer (server)
You must call
createSignalServer() once (e.g. in lib/signal-server.ts) before using the server helpers below. The helpers use the same singleton client.
Server helpers
These utilities are exported from@signal-js/nextjs/server. They work with the client created by createSignalServer().
trackServerEvent(options)
Fire a single event from an API route or Server Action without importing your sharedsignal client. Uses the singleton from createSignalServer; call createSignalServer() at least once (e.g. in lib/signal-server.ts) before using.
When to use: One-off event tracking in API routes or Server Actions when you don’t need to pass
sessionId/windowId for correlation. For session correlation, use your shared signal client and getSessionInfo instead.
getSignalServerSideProps(getServerSidePropsFunc, options?)
Wrap your Pages RoutergetServerSideProps to inject Signal-related props (distinctId, sessionId) into the page. Your wrapper runs first; then Signal props are merged into the returned props.
When to use: Pages Router when you want Signal context (e.g.
distinctId, sessionId) available as page props for client components or for tracking.
withSignalConfig(signalConfig)
Wrap your Next.js config to inject Signal env vars for the client:NEXT_PUBLIC_SIGNAL_ENDPOINT and NEXT_PUBLIC_SIGNAL_PROJECT_ID. This is an alternative to setting them in .env.local.
When to use: When you prefer to configure Signal in
next.config.js instead of (or in addition to) .env.local.
process.env.NEXT_PUBLIC_SIGNAL_ENDPOINT and process.env.NEXT_PUBLIC_SIGNAL_PROJECT_ID at build time. Keep apiKey and other secrets in server-only env (e.g. SIGNAL_API_KEY in .env.local).
Browser options (options prop)
Clientoptions are the same browser SDK options as in React — Configuration. That page includes:
- Transport and batching —
compression,flushInterval,maxBatchSize,getSignedUploadUrl - Features —
enableSessionReplay,enableNetworkCapture,enableConsoleCapture,enableSessionTracking,enablePerformanceTracking,enableBrowserDetection,debug - sessionRecordingMasking — How masking works: blockClass/blockSelector (hide elements), maskTextClass/maskTextSelector (replace text with ***), ignoreClass (don’t record input values), maskAllInputs vs maskInputOptions (per-type input masking), maskTextFn/maskInputFn (custom transforms). With examples and JSX usage.
- networkCaptureOptions — How network capture works: recordHeaders/recordBody (what is captured), sensitiveHeaders (redact header values), urlDenyList (exclude URLs), payloadSizeLimitBytes (truncate large bodies), maskRequestFn (custom redaction or drop). With examples.
- consoleCaptureOptions —
levels,captureErrors,captureUnhandledRejections,stringLengthLimit,maskSensitiveData - Session and advanced —
sessionId,sessionIdleTimeoutSeconds,maxSessionLengthSeconds,addTracingHeaders(for server correlation),rrwebConfig,requiredBrowserFeatures,debugPersistToLocalStorage,debugLocalStorageKey
See also
- Initialization — Client and server setup
