npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@vigilon/nextjs

v0.2.25

Published

Vigilon monitoring for Next.js applications: server traces and browser errors

Downloads

3,061

Readme

@vigilon/nextjs

Vigilon for Next.js: server traces and errors from the Node.js runtime, and browser errors from the client, reported under one service. It wraps @vigilon/node on the server and @vigilon/react in the browser.

Requires Next.js 15.3 or later, and Node.js 22.12 or later for the build and the server. Automatic source map upload needs Next.js 15.4 or later.

Install

npm install @vigilon/nextjs

Set up

API keys

In the Vigilon dashboard, open your project's Settings page, then the API Keys tab, and create two keys:

  • one of kind Server for the Node.js runtime, set as VIGILON_API_KEY;
  • one of kind Browser for the client, set as NEXT_PUBLIC_VIGILON_API_KEY.

Under the browser key's Allowed origins, you can list your site's origins, one per line; https://*.example.com covers every subdomain, and an empty list accepts any origin. Requests from any other origin get HTTP 403. The browser key is built into your client JavaScript, where anyone can read it, so never use the server key there.

next.config.ts

import { withVigilon } from "@vigilon/nextjs/config";

export default withVigilon({
  // your Next.js config
});

withVigilon() keeps the SDK and its OpenTelemetry dependencies out of the server bundle, and has Next.js render the request's traceparent in a meta tag so browser errors on a server-rendered page link to the server trace that rendered it.

instrumentation.ts (server)

export async function register() {
  if (process.env.NEXT_RUNTIME === "nodejs") {
    const { register } = await import("@vigilon/nextjs/server");
    register({ appName: "storefront", appVersion: process.env.VIGILON_APP_VERSION });
  }
}

register() takes the same options as @vigilon/node and reads anything you leave out from the environment (VIGILON_API_KEY, VIGILON_ENVIRONMENT, …). It adds what Next.js needs on top: request spans are labelled with the route Next.js resolved (/api/orders/[id]), and on Vercel telemetry is flushed at the end of every request and the real response status is recorded. The SDK cannot run in the Edge runtime, so gate on NEXT_RUNTIME and import it dynamically as above.

Next.js records errors from Server Components, route handlers, and Server Actions on its own request spans, so no onRequestError hook is needed. Everything from @vigilon/node (recordException, withJobMonitor, …) is re-exported from @vigilon/nextjs/server.

instrumentation-client.ts (browser)

import { init } from "@vigilon/nextjs";

init({
  apiKey: process.env.NEXT_PUBLIC_VIGILON_API_KEY!,
  appName: "storefront",
  environment: process.env.NEXT_PUBLIC_VIGILON_ENVIRONMENT!,
  appVersion: process.env.NEXT_PUBLIC_VIGILON_APP_VERSION,
});

Use the same appName as the server: Vigilon keeps server and browser errors apart by origin. init takes the options of @vigilon/browser. Every event captured before the first client-side navigation carries the trace ID of the request that rendered the page.

Error boundaries

Next.js creates the React root itself, so render errors that an error.tsx or global-error.tsx boundary catches are reported from the boundary:

"use client";
import { useReportError } from "@vigilon/nextjs";

export default function GlobalError({ error }: { error: Error & { digest?: string } }) {
  useReportError(error);
  return (
    <html lang="en">
      <body>
        <h2>Something went wrong.</h2>
      </body>
    </html>
  );
}

Errors thrown on the server, in a Server Component or a Server Action, reach these boundaries with their message redacted and a digest. Next.js already records them on the server, so useReportError skips any error that has a digest rather than reporting the redacted copy again.

@vigilon/nextjs re-exports @vigilon/react, including ErrorBoundary for your own boundaries inside client components.

Source maps

With a source map upload token, withVigilon() builds browser source maps and, once Next.js has compiled, gives every script a debug ID, uploads the scripts and their maps, and deletes every map so none is deployed. Before that it marks, in each map's ignoreList, the sources that are not files in your project, such as the precompiled Next.js code a webpack build maps, so Vigilon treats their frames as library code rather than yours. Files outside the project directory that exist on disk, such as a shared package in a monorepo, stay yours. It runs in Next.js's compiler.runAfterProductionCompile hook (Next.js 15.4 or later), so it works with both Turbopack and webpack.

Create the upload token on your project's Settings page, Source Maps tab, and set it as VIGILON_SOURCE_MAP_TOKEN where next build runs, such as a CI secret. Never give it a NEXT_PUBLIC_ name: anyone with it can replace your source maps.

VIGILON_SOURCE_MAP_TOKEN=vg_sm_... next build

| Option | Default | | |---|---|---| | uploadToken | VIGILON_SOURCE_MAP_TOKEN | A source map upload token for the project, starting with vg_sm_. Without one, no source maps are built or uploaded. An API key does not work here. | | apiUrl | VIGILON_API_URL, then https://api.vigilon.io | The Vigilon API. | | onUploadError | "error" | "warn" keeps a failed upload from failing the build. The maps are deleted either way. |

export default withVigilon(nextConfig, { onUploadError: "warn" });

On Next.js 15.3, run @vigilon/cli on .next/static after next build instead, with productionBrowserSourceMaps: true.

Self-hosted Next.js (optional)

With next start or the standalone output you can preload the SDK instead of, or as well as, registering it from instrumentation.ts, which adds Vigilon's own HTTP server spans:

NODE_OPTIONS='--import @vigilon/nextjs/register' next start

The preload reads its settings from the environment. Preload this package's entry, not @vigilon/node/register: a plain @vigilon/node start has no Next.js route labelling, and register() from this package then warns and does nothing. Preloading does not work on Vercel; use instrumentation.ts there.

Support