Skip to main content

Next.js — Capture

Track custom events from client components (using React hooks) and from the server (API routes, Server Actions). Pass sessionId and windowId from request headers on the server to correlate with the client session.

Client: useSignalCapture or useSignal

In any client component, use the same hooks as the React integration:
You can also use useSignal() for full SDK access. Both are re-exported from @signal-js/nextjs/client.

Server: API route (App Router)

Import your server client and getSessionInfo, then call signal.capture() with the session identifiers from the request:

Server: Server Action

Read headers with headers() from next/headers and pass them into signal.capture():
For Pages Router API routes and getServerSideProps, see Server tracking.

See also