# Pagerless for Next.js

> One line in instrumentation.ts covers pages, layouts, route handlers, server actions and middleware, on Node and the edge.

URL: https://pagerless.dev/integrations/nextjs
Updated: 2026-10-22

## Set up

```bash
npm i pagerless
```

```ts
export { register, onRequestError } from "pagerless/next";
```

Works with the app router and the pages router. `onRequestError` needs Next.js 15 or newer. Edge route handlers can also be wrapped: `export const GET = withPagerless(handler)`.

`npx pagerless connect` writes this file for you when it finds `next` in package.json.

## What it catches

- Errors in pages, layouts, route handlers, server actions and middleware.
- Reports 5xx and crashes only, never 4xx, and leaves the response, logs and error exactly as they were.
- On Node it also starts the SDK: uncaught errors and unhandled rejections, status and latency per route, failing outbound calls (Stripe, OpenAI, Supabase and others named), a heartbeat every 60 seconds and a deploy marker.

## Questions

### Does it catch errors in React components in the browser?

Add [pagerless/browser](https://pagerless.dev/integrations/browser) and, if you like, the [React error boundary](https://pagerless.dev/integrations/react).

### Can Pagerless roll back a bad Next.js deploy?

On Vercel and Netlify, yes, after your approval. See [Next.js on Vercel](https://pagerless.dev/integrations/nextjs-vercel).
