Skip to content

Next.js on Vercel

Set up @sypnia/telemetry/next for an app deployed on Vercel, with the environment variables, what preview deployments report, source maps at build, and the ad-blocker route.

Applies to EngineCloud
View as Markdown
On this page
  1. Add the package and the three files
  2. Set the variables in Vercel
  3. Deploy and read the build log
  4. Open the deployment
  5. What Vercel gives Sypnia by itself
  6. Functions
  7. Visitors with ad blockers
  8. If the app already uses OpenTelemetry
  9. Check the whole thing

This guide is for a Next.js app that Vercel builds and hosts. It applies to Sypnia Cloud and to a self-hosted engine; the variables that differ are marked. It builds on Next.js, which has every option.

At the end you will have: production and preview deployments reporting to Sypnia under separate environments, each deploy registered as a release with its source maps, and server requests traced inside Vercel’s functions.

You need: Next.js 15.3 or newer, a Sypnia project with its ingest key, and an API token with the ci scope for source maps.

  1. Add the package and the three files

    Terminal
    npm install @sypnia/telemetry
    next.config.ts
    import type { NextConfig } from 'next';
    import { withSypnia } from '@sypnia/telemetry/next';
    
    const nextConfig: NextConfig = {};
    
    export default withSypnia(nextConfig, { service: 'shop-web' });
    instrumentation.ts
    export { register, onRequestError } from '@sypnia/telemetry/next/server';
    instrumentation-client.ts
    import { init } from '@sypnia/telemetry/next/client';
    
    init();
    
    export { onRouterTransitionStart } from '@sypnia/telemetry/next/client';

    Nothing else in the code: the key, the environment and the release come from variables.

  2. Set the variables in Vercel

    In your project on Vercel, open the environment variables settings and add:

    VariableValueEnvironmentsSensitive
    SYPNIA_PROJECT_KEYYour ingest key, spk_…Production, Preview, DevelopmentNo. It is public.
    SYPNIA_API_TOKENAn API token with ci, sps_…Production (and Preview, if you want source maps there)Yes. Mark it as sensitive.
    SYPNIA_ENDPOINTYour engine’s base URLAllSelf-hosted only.
    SYPNIA_BASE_URLYour engine’s base URLThe same as the tokenSelf-hosted only.

    Do not prefix any of them with NEXT_PUBLIC_. withSypnia passes the public ones to the browser itself, and the token must never reach it.

    You should see
    The variables are listed in the project. The next deployment uses them; existing deployments do not change.
  3. Deploy and read the build log

    Push a commit, or redeploy.

    You should see
    Near the end of the build log: Sypnia: release 4f2a91c registered, 312 source maps uploaded, 312 removed from the build output. The release is the first 7 characters of the commit Vercel built.

    If it says source maps not uploaded (SYPNIA_API_TOKEN is not set), the token is missing from the environment that was built.

  4. Open the deployment

    Open your production address, click around, and look at Sessions in Sypnia with the environment production.

    You should see
    Your session within 10 minutes. In Traces, requests to your Route Handlers and pages with their outgoing calls.

What Vercel gives Sypnia by itself

withSypnia reads Vercel’s own variables, so you set neither value:

SypniaComes fromResult
environmentVERCEL_ENVproduction for the production deployment, preview for every preview deployment, development under next dev and vercel dev.
releaseVERCEL_GIT_COMMIT_SHA, first 7 charactersThe commit that was built, the same on the browser, the server and the source maps.

This needs «Automatically expose System Environment Variables» to be on in the project, which is Vercel’s default; check Vercel’s current documentation if release comes out empty.

What this means in practice:

  • Previews do not alert you. Alerts and the daily summary cover production only. A bug you see in a preview is a problem in the preview environment, separate from production.
  • Previews do count towards a Sypnia Cloud plan, like every environment. If you open many previews, leave SYPNIA_PROJECT_KEY out of the Preview environment to keep them silent.
  • Each deploy is a release, so a problem can say «since the deploy of 18:40» and name its commit.

Functions

Server code on Vercel runs in functions that are frozen as soon as the response is sent. @sypnia/telemetry/next exports each request’s spans as OTLP, in protobuf, to Sypnia’s OTLP endpoint, with the mechanism Next.js and Vercel provide for work after the response (waitUntil), so tracing adds no wait to your responses and loses nothing when the function is frozen. There is nothing to configure.

Cold starts. @sypnia/telemetry/next does not depend on OpenTelemetry and installs no loader hooks, so a cold start loads one small module. Our target is under 50 ms added to a cold start. For comparison, the official OpenTelemetry Node SDK added 600–800 ms before a server could answer in our measurement of 2026-11-15; the method and the other numbers are on Node.

Two limits:

  • Routes and middleware on the Edge runtime are not traced and their errors are not reported.
  • A function that Vercel stops at its maximum duration cannot send its finished spans. Sypnia still gets the partial span exported at 20 seconds, with the calls that were in flight. See Traces.

Visitors with ad blockers

Send through your own domain so the requests are not blocked by host name. Add a rewrite and tell the browser side to use it:

next.config.ts
const nextConfig: NextConfig = {
  async rewrites() {
    return [{ source: '/_sy/:path*', destination: 'https://telemetry.ingest.sypnia.com/:path*' }];
  },
};
instrumentation-client.ts
init({ endpoint: '/_sy' });

The server side keeps sending straight to ingest. On a self-hosted engine use your engine’s base URL as the destination.

If the app already uses OpenTelemetry

Apps that already call registerOTel from @vercel/otel in instrumentation.ts have two choices. The simplest is to keep it and send its traces to Sypnia with the standard variables, instead of adding Sypnia’s register. The other is the @sypnia/telemetry/otel bridge, which adds Sypnia to the OpenTelemetry setup you have, at the measured cost of the OpenTelemetry SDK, which you already pay. The first one:

Vercel environment variables
OTEL_EXPORTER_OTLP_ENDPOINT=https://telemetry.ingest.sypnia.com/v1/otlp
OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer%20spk_7d1f0c9e4b8a2f6d3c5e1a9b0f4d8c2e

The space after Bearer is written %20: the variable uses the W3C Baggage format, and @vercel/otel decodes it.

instrumentation.ts
import { registerOTel } from '@vercel/otel';

export function register() {
  registerOTel({ serviceName: 'shop-web' });
}

export { onRequestError } from '@sypnia/telemetry/next/server';

Keep instrumentation-client.ts as above. See OpenTelemetry for the choice, and the semantic conventions for what each span becomes.

With the bridge instead, registerOTel takes Sypnia’s processor in spanProcessors, and that list replaces @vercel/otel’s default processors. Use spanProcessors: [s.spanProcessor] when Sypnia is the only destination; use spanProcessors: ['auto', s.spanProcessor] when the app also exports elsewhere through those defaults, such as Vercel’s own trace view. The whole setup is in OpenTelemetry bridge.

Check the whole thing

CheckWhereYou should see
The browser sendsNetwork tab, filter ingest (or _sy)POST …/v1/ingest/events, 200
The server sendsSypnia, Traces, environment productionYour routes, with spans
The release is setAny sessionRelease 4f2a91c, the deployed commit
Source maps applyThe next problem’s stacksrc/checkout/checkout.tsx:142, not …-8d21e07b.js:1:48211
Previews are separateEnvironment previewOnly sessions from preview addresses
  1. Add the package and the three files
  2. Set the variables in Vercel
  3. Deploy and read the build log
  4. Open the deployment
  5. What Vercel gives Sypnia by itself
  6. Functions
  7. Visitors with ad blockers
  8. If the app already uses OpenTelemetry
  9. Check the whole thing

    Search pages, sections and terms