{"_id":"@arguslog/sdk-nextjs","_rev":"6-1850db10bd46c2c59ee247f5515d95a7","name":"@arguslog/sdk-nextjs","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"@arguslog/sdk-nextjs","version":"1.0.0","license":"MIT","_id":"@arguslog/sdk-nextjs@1.0.0","maintainers":[{"name":"petar.nenov","email":"petarnenovpetrov@gmail.com"}],"dist":{"shasum":"1412ffd9e8d6a69537c9079481c243577ed184f8","tarball":"https://registry.npmjs.org/@arguslog/sdk-nextjs/-/sdk-nextjs-1.0.0.tgz","fileCount":27,"integrity":"sha512-fw5UFk64sfqpTc8/KPOwB5sVzhj4a8XIandou6TfkssakLa2SjLl56aogzbty9sk4wrch9I//1x1DHmba09w+g==","signatures":[{"sig":"MEUCIQC1RzH6f8OyKVqegnunEpE2nY98fS2VYo+mha01dMT67gIgLRSdn6/SKa/cBNZl2yz3YMtC9vHltWQ4DJPljM0fuQ8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18877},"main":"./dist/client.js","type":"module","_from":"file:arguslog-sdk-nextjs-1.0.0.tgz","types":"./dist/client.d.ts","module":"./dist/client.js","exports":{"./client":{"types":"./dist/client.d.ts","import":"./dist/client.js"},"./server":{"types":"./dist/server.d.ts","import":"./dist/server.js"}},"scripts":{"dev":"tsc -p tsconfig.build.json --watch","lint":"eslint src","test":"vitest run","build":"tsc -p tsconfig.build.json","clean":"rm -rf dist .turbo","typecheck":"tsc --noEmit","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"petar.nenov","email":"petarnenovpetrov@gmail.com"},"_resolved":"/tmp/00ff6d8042f458c91117cf5f1d88b464/arguslog-sdk-nextjs-1.0.0.tgz","_integrity":"sha512-fw5UFk64sfqpTc8/KPOwB5sVzhj4a8XIandou6TfkssakLa2SjLl56aogzbty9sk4wrch9I//1x1DHmba09w+g==","_npmVersion":"10.9.7","description":"Arguslog Next.js SDK — App Router + Pages Router, route handler & server action wrappers, instrumentation.ts hook","directories":{},"sideEffects":false,"_nodeVersion":"22.22.2","dependencies":{"@arguslog/sdk-node":"1.0.0","@arguslog/sdk-react":"1.1.0"},"_hasShrinkwrap":false,"devDependencies":{"next":"^15.0.0","react":"^19.0.0","eslint":"^9.18.0","vitest":"^3.2.4","typescript":"^5.7.0","@types/node":"^22.10.0","@types/react":"^19.0.0","@arguslog/tsconfig":"0.0.0","@vitest/coverage-v8":"^3.2.4","@arguslog/eslint-config":"0.0.0"},"peerDependencies":{"next":">=13.4.0 <16.0.0","react":"^18.0.0 || ^19.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sdk-nextjs_1.0.0_1778254911340_0.4629085241886517","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@arguslog/sdk-nextjs","version":"1.0.1","license":"MIT","_id":"@arguslog/sdk-nextjs@1.0.1","maintainers":[{"name":"petar.nenov","email":"petarnenovpetrov@gmail.com"}],"dist":{"shasum":"69ea1899fcb22f804d95c61295208554e6a27a0f","tarball":"https://registry.npmjs.org/@arguslog/sdk-nextjs/-/sdk-nextjs-1.0.1.tgz","fileCount":27,"integrity":"sha512-HpeYUZZV2f++3vppeTPVvpWBTLocC1z2M6weAA8ELRKfPx+Z410DCvumFPJY87qRjYWThclbeBQE4li6o79EYA==","signatures":[{"sig":"MEUCIH7qzYq05fDXarkmP9pfg/1TPo+Ul0RoDLpzVKrEgbWcAiEAll/DJmtErzKqV46lHNeEmhTYlF711HNNg6yw44rOiDU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":28032},"main":"./dist/client.js","type":"module","_from":"file:arguslog-sdk-nextjs-1.0.1.tgz","types":"./dist/client.d.ts","module":"./dist/client.js","exports":{"./client":{"types":"./dist/client.d.ts","import":"./dist/client.js"},"./server":{"types":"./dist/server.d.ts","import":"./dist/server.js"}},"scripts":{"dev":"tsc -p tsconfig.build.json --watch","lint":"eslint src","test":"vitest run","build":"tsc -p tsconfig.build.json","clean":"rm -rf dist .turbo","typecheck":"tsc --noEmit","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"petar.nenov","email":"petarnenovpetrov@gmail.com"},"_resolved":"/tmp/865490c981dcf15d367424eaf0452eab/arguslog-sdk-nextjs-1.0.1.tgz","_integrity":"sha512-HpeYUZZV2f++3vppeTPVvpWBTLocC1z2M6weAA8ELRKfPx+Z410DCvumFPJY87qRjYWThclbeBQE4li6o79EYA==","_npmVersion":"10.9.7","description":"Arguslog Next.js SDK — App Router + Pages Router, route handler & server action wrappers, instrumentation.ts hook","directories":{},"sideEffects":false,"_nodeVersion":"22.22.2","dependencies":{"@arguslog/sdk-node":"1.0.1","@arguslog/sdk-react":"1.1.0"},"_hasShrinkwrap":false,"devDependencies":{"next":"^15.0.0","react":"^19.0.0","eslint":"^9.18.0","vitest":"^3.2.4","typescript":"^5.7.0","@types/node":"^22.10.0","@types/react":"^19.0.0","@arguslog/tsconfig":"0.0.0","@vitest/coverage-v8":"^3.2.4","@arguslog/eslint-config":"0.0.0"},"peerDependencies":{"next":">=13.4.0 <16.0.0","react":"^18.0.0 || ^19.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sdk-nextjs_1.0.1_1778264951711_0.30241496516030186","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@arguslog/sdk-nextjs","version":"1.0.2","license":"MIT","_id":"@arguslog/sdk-nextjs@1.0.2","maintainers":[{"name":"petar.nenov","email":"petarnenovpetrov@gmail.com"}],"dist":{"shasum":"e41bc437db41d4c31e458d3e628784e9f1c62e1c","tarball":"https://registry.npmjs.org/@arguslog/sdk-nextjs/-/sdk-nextjs-1.0.2.tgz","fileCount":27,"integrity":"sha512-dwSvdbkGI5KlhIkKRGNeMXM0B8leu6th+ynXWT++3WjHprxHaFo2QnSsvJ91aKZ39308PBa0Qw8Keh+/2k8i1Q==","signatures":[{"sig":"MEUCIC4l5PeGBYaF900cZbMGthrp5UssteDkoFEFH9BHsZPzAiEAvzjTZqJ3KYBmm4D1+LHEw9aM68YD3gzPq/cQv+i8pP0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":28032},"main":"./dist/client.js","type":"module","_from":"file:arguslog-sdk-nextjs-1.0.2.tgz","types":"./dist/client.d.ts","module":"./dist/client.js","exports":{"./client":{"types":"./dist/client.d.ts","import":"./dist/client.js"},"./server":{"types":"./dist/server.d.ts","import":"./dist/server.js"}},"scripts":{"dev":"tsc -p tsconfig.build.json --watch","lint":"eslint src","test":"vitest run","build":"tsc -p tsconfig.build.json","clean":"rm -rf dist .turbo","typecheck":"tsc --noEmit","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"petar.nenov","email":"petarnenovpetrov@gmail.com"},"_resolved":"/tmp/0ba9f031dbabd5bb03495760d23ac424/arguslog-sdk-nextjs-1.0.2.tgz","_integrity":"sha512-dwSvdbkGI5KlhIkKRGNeMXM0B8leu6th+ynXWT++3WjHprxHaFo2QnSsvJ91aKZ39308PBa0Qw8Keh+/2k8i1Q==","_npmVersion":"10.9.7","description":"Arguslog Next.js SDK — App Router + Pages Router, route handler & server action wrappers, instrumentation.ts hook","directories":{},"sideEffects":false,"_nodeVersion":"22.22.2","dependencies":{"@arguslog/sdk-node":"1.0.2","@arguslog/sdk-react":"1.1.1"},"_hasShrinkwrap":false,"devDependencies":{"next":"^15.0.0","react":"^19.0.0","eslint":"^9.18.0","vitest":"^3.2.4","typescript":"^5.7.0","@types/node":"^22.10.0","@types/react":"^19.0.0","@arguslog/tsconfig":"0.0.0","@vitest/coverage-v8":"^3.2.4","@arguslog/eslint-config":"0.0.0"},"peerDependencies":{"next":">=13.4.0 <16.0.0","react":"^18.0.0 || ^19.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sdk-nextjs_1.0.2_1778358389153_0.6134605981391192","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@arguslog/sdk-nextjs","version":"1.0.3","license":"MIT","_id":"@arguslog/sdk-nextjs@1.0.3","maintainers":[{"name":"petar.nenov","email":"petarnenovpetrov@gmail.com"}],"dist":{"shasum":"7023fbca4a0edb0301640e3fb3990a52798457ff","tarball":"https://registry.npmjs.org/@arguslog/sdk-nextjs/-/sdk-nextjs-1.0.3.tgz","fileCount":27,"integrity":"sha512-xnhwjiOuEb8KUdG6JUp+d3LVVDxqilPCq13GzFSXji1Dld0H1VQuI70ivixP8pKM2WRExjFX1baNqOpWG8q+Hg==","signatures":[{"sig":"MEYCIQCLgOIeuh1cQmFp2do2MSAyYI1SAGX9PN25XtPil5cGVgIhAMuZvjKOPo+1BDE/zPNVN7E45NNPQxdGymVrKDEspEov","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":28036},"main":"./dist/client.js","type":"module","_from":"file:arguslog-sdk-nextjs-1.0.3.tgz","types":"./dist/client.d.ts","module":"./dist/client.js","exports":{"./client":{"types":"./dist/client.d.ts","import":"./dist/client.js"},"./server":{"types":"./dist/server.d.ts","import":"./dist/server.js"}},"scripts":{"dev":"tsc -p tsconfig.build.json --watch","lint":"eslint src","test":"vitest run","build":"tsc -p tsconfig.build.json","clean":"rm -rf dist .turbo","typecheck":"tsc --noEmit","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"petar.nenov","email":"petarnenovpetrov@gmail.com"},"_resolved":"/tmp/e5253f8684a0d7604e4efd98eeccc1bf/arguslog-sdk-nextjs-1.0.3.tgz","_integrity":"sha512-xnhwjiOuEb8KUdG6JUp+d3LVVDxqilPCq13GzFSXji1Dld0H1VQuI70ivixP8pKM2WRExjFX1baNqOpWG8q+Hg==","_npmVersion":"10.9.7","description":"Arguslog Next.js SDK — App Router + Pages Router, route handler & server action wrappers, instrumentation.ts hook","directories":{},"sideEffects":false,"_nodeVersion":"22.22.2","dependencies":{"@arguslog/sdk-node":"1.0.2","@arguslog/sdk-react":"1.1.2"},"_hasShrinkwrap":false,"devDependencies":{"next":"^15.0.0","react":"^19.0.0","eslint":"^9.18.0","vitest":"^3.2.4","typescript":"^5.7.0","@types/node":"^22.10.0","@types/react":"^19.0.0","@arguslog/tsconfig":"0.0.0","@vitest/coverage-v8":"^3.2.4","@arguslog/eslint-config":"0.0.0"},"peerDependencies":{"next":">=13.4.0 <16.0.0","react":"^18.0.0 || ^19.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sdk-nextjs_1.0.3_1778361174765_0.05129999753735337","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@arguslog/sdk-nextjs","version":"1.0.4","license":"MIT","_id":"@arguslog/sdk-nextjs@1.0.4","maintainers":[{"name":"petar.nenov","email":"petarnenovpetrov@gmail.com"}],"dist":{"shasum":"8e81e95767884494f0925005dd97cb36327e74fd","tarball":"https://registry.npmjs.org/@arguslog/sdk-nextjs/-/sdk-nextjs-1.0.4.tgz","fileCount":27,"integrity":"sha512-l0BJYWLlyTyvixK0t7WsSc36J+KUvMpGUDUqbRRv0mzAm0AKkshPYqPCdEZXJ56fEWZ2JZ4H0+SwfYBcMa9Rmg==","signatures":[{"sig":"MEYCIQDERBwO+cgBe0NIL2sBt57NbNPKkWMIq9GNAfvy68QtNQIhAIRXgjkm60MfUTdKEbVhbGt2EA472buy7ABiJ4Y83243","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":28036},"main":"./dist/client.js","type":"module","_from":"file:arguslog-sdk-nextjs-1.0.4.tgz","types":"./dist/client.d.ts","module":"./dist/client.js","exports":{"./client":{"types":"./dist/client.d.ts","import":"./dist/client.js"},"./server":{"types":"./dist/server.d.ts","import":"./dist/server.js"}},"scripts":{"dev":"tsc -p tsconfig.build.json --watch","lint":"eslint src","test":"vitest run","build":"tsc -p tsconfig.build.json","clean":"rm -rf dist .turbo","typecheck":"tsc --noEmit","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"petar.nenov","email":"petarnenovpetrov@gmail.com"},"_resolved":"/tmp/7a9717fee7665734ebdd8c1f10dcb9be/arguslog-sdk-nextjs-1.0.4.tgz","_integrity":"sha512-l0BJYWLlyTyvixK0t7WsSc36J+KUvMpGUDUqbRRv0mzAm0AKkshPYqPCdEZXJ56fEWZ2JZ4H0+SwfYBcMa9Rmg==","_npmVersion":"10.9.7","description":"Arguslog Next.js SDK — App Router + Pages Router, route handler & server action wrappers, instrumentation.ts hook","directories":{},"sideEffects":false,"_nodeVersion":"22.22.2","dependencies":{"@arguslog/sdk-node":"1.0.2","@arguslog/sdk-react":"1.1.3"},"_hasShrinkwrap":false,"devDependencies":{"next":"^15.0.0","react":"^19.0.0","eslint":"^9.18.0","vitest":"^3.2.4","typescript":"^5.7.0","@types/node":"^22.10.0","@types/react":"^19.0.0","@arguslog/tsconfig":"0.0.0","@vitest/coverage-v8":"^3.2.4","@arguslog/eslint-config":"0.0.0"},"peerDependencies":{"next":">=13.4.0 <16.0.0","react":"^18.0.0 || ^19.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sdk-nextjs_1.0.4_1778363889222_0.38109767989975696","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@arguslog/sdk-nextjs","version":"2.0.0","description":"Arguslog Next.js SDK — App Router + Pages Router, route handler & server action wrappers, instrumentation.ts hook","license":"MIT","type":"module","main":"./dist/client.js","module":"./dist/client.js","types":"./dist/client.d.ts","exports":{"./client":{"types":"./dist/client.d.ts","import":"./dist/client.js"},"./server":{"types":"./dist/server.d.ts","import":"./dist/server.js"}},"sideEffects":false,"dependencies":{"@arguslog/sdk-node":"2.0.0","@arguslog/sdk-react":"2.0.0"},"peerDependencies":{"next":">=13.4.0 <16.0.0","react":"^18.0.0 || ^19.0.0"},"devDependencies":{"@types/node":"^22.10.0","@types/react":"^19.0.0","@vitest/coverage-v8":"^3.2.4","eslint":"^9.18.0","next":"^15.0.0","react":"^19.0.0","typescript":"^5.7.0","vitest":"^3.2.4","@arguslog/tsconfig":"0.0.0","@arguslog/eslint-config":"0.0.0"},"repository":{"type":"git","url":"git+https://github.com/petarnenov/arguslog-sdks.git","directory":"packages/sdk-nextjs"},"homepage":"https://arguslog.org","bugs":{"url":"https://github.com/petarnenov/arguslog-sdks/issues"},"scripts":{"build":"tsc -p tsconfig.build.json","dev":"tsc -p tsconfig.build.json --watch","lint":"eslint src","typecheck":"tsc --noEmit","test":"vitest run","test:coverage":"vitest run --coverage","clean":"rm -rf dist .turbo"},"_id":"@arguslog/sdk-nextjs@2.0.0","_integrity":"sha512-aLcokEM9YGVSaPr5qxmDhUblHpxXBcd7wu1lmSAUmSd2ym8DAC3bC2sZTENCyab5F2iPhFKgKBeyZFvUJYw9dQ==","_resolved":"/tmp/299e16e5105b5f59b9dd30b3be7d59b1/arguslog-sdk-nextjs-2.0.0.tgz","_from":"file:arguslog-sdk-nextjs-2.0.0.tgz","_nodeVersion":"22.22.2","_npmVersion":"10.9.7","dist":{"integrity":"sha512-aLcokEM9YGVSaPr5qxmDhUblHpxXBcd7wu1lmSAUmSd2ym8DAC3bC2sZTENCyab5F2iPhFKgKBeyZFvUJYw9dQ==","shasum":"5bad42d387c0a29ce6a0b5ad3842f99fd1c78228","tarball":"https://registry.npmjs.org/@arguslog/sdk-nextjs/-/sdk-nextjs-2.0.0.tgz","fileCount":28,"unpackedSize":28738,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQD5awQeOM7vLrvW7fz21YyVMIV92HeADxr6D+GwWb83jwIgYJg1o7BGdx2RRcmiacHQJBwxX3EVagotxyhifUjSpK4="}]},"_npmUser":{"name":"petar.nenov","email":"petarnenovpetrov@gmail.com"},"directories":{},"maintainers":[{"name":"petar.nenov","email":"petarnenovpetrov@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk-nextjs_2.0.0_1778619540021_0.8858606618939373"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-08T15:41:51.255Z","modified":"2026-05-12T20:59:00.403Z","1.0.0":"2026-05-08T15:41:51.489Z","1.0.1":"2026-05-08T18:29:11.861Z","1.0.2":"2026-05-09T20:26:29.288Z","1.0.3":"2026-05-09T21:12:54.926Z","1.0.4":"2026-05-09T21:58:09.363Z","2.0.0":"2026-05-12T20:59:00.252Z"},"license":"MIT","description":"Arguslog Next.js SDK — App Router + Pages Router, route handler & server action wrappers, instrumentation.ts hook","maintainers":[{"name":"petar.nenov","email":"petarnenovpetrov@gmail.com"}],"readme":"# @arguslog/sdk-nextjs\n\n[![npm version](https://img.shields.io/npm/v/@arguslog/sdk-nextjs.svg)](https://www.npmjs.com/package/@arguslog/sdk-nextjs)\n[![license](https://img.shields.io/npm/l/@arguslog/sdk-nextjs.svg)](https://github.com/petarnenov/arguslog/blob/main/LICENSE)\n\nNext.js SDK for [Arguslog](https://arguslog.org) — a multi-tenant error tracking platform.\nWraps [`@arguslog/sdk-react`](https://www.npmjs.com/package/@arguslog/sdk-react) for the\nclient and [`@arguslog/sdk-node`](https://www.npmjs.com/package/@arguslog/sdk-node) for\nthe server, plus helpers for App Router route handlers, server actions, Pages Router API\nroutes, and the `instrumentation.ts` `onRequestError` hook introduced in Next.js 15.\n\nShips ESM only. Supports Next.js 13.4 through 15.x, React 18 or 19, on both Node.js and\nthe Edge runtime.\n\n## Install\n\n```bash\npnpm add @arguslog/sdk-nextjs\n# or\nnpm install @arguslog/sdk-nextjs\n# or\nyarn add @arguslog/sdk-nextjs\n```\n\nThe package exposes two import paths:\n\n- `@arguslog/sdk-nextjs/server` — Node-only helpers (route wrappers, instrumentation).\n- `@arguslog/sdk-nextjs/client` — browser/RSC client helpers (re-exports from `sdk-react`).\n\nThere is no default export — pick the one that matches the file you're editing.\n\n## Server: `instrumentation.ts` (recommended)\n\nNext.js 15 introduced the `instrumentation.ts` file conventions. Create\n`instrumentation.ts` at the repo root (or `src/instrumentation.ts` if you use `src/`):\n\n```ts\nimport type { Instrumentation } from 'next';\n\nexport async function register() {\n  if (process.env.NEXT_RUNTIME === 'nodejs') {\n    const { init } = await import('@arguslog/sdk-nextjs/server');\n    init({\n      dsn: process.env.ARGUSLOG_DSN!,\n      release: process.env.RELEASE,\n      environment: process.env.NODE_ENV,\n      integrations: ['processHandlers', 'http'],\n      sourcemaps: { enabled: true },\n    });\n  }\n}\n\nexport const onRequestError: Instrumentation.onRequestError = async (err, request, ctx) => {\n  const { onRequestError } = await import('@arguslog/sdk-nextjs/server');\n  onRequestError(err, request, ctx);\n};\n```\n\n`onRequestError` runs for every error thrown during a request, regardless of router\n(App or Pages), runtime (Node or Edge), or kind (`render`, `route`, `action`,\n`middleware`). The exported helper tags events with the route, router kind, route type,\nand HTTP method so you can filter on them in the dashboard.\n\nThe dynamic `import()` matters: it keeps the Node SDK out of Edge bundles when Next\nbuilds for both runtimes.\n\n## App Router: route handlers\n\nFor App Router endpoints under `app/api/.../route.ts`, wrap your handler so any\nunhandled throw is captured before being re-thrown for Next to render the error page:\n\n```ts\nimport { wrapRouteHandler } from '@arguslog/sdk-nextjs/server';\nimport { NextResponse } from 'next/server';\n\nexport const POST = wrapRouteHandler(async (req: Request) => {\n  const body = await req.json();\n  const result = await chargeCard(body); // throws on failure\n  return NextResponse.json(result);\n});\n```\n\n`wrapRouteHandler` is a no-op on success and `captureException` + rethrow on failure, so\nyour existing error-rendering chain (Next's `error.tsx`, custom error pages) keeps\nworking.\n\n## App Router: server actions\n\n```ts\n'use server';\n\nimport { wrapServerAction } from '@arguslog/sdk-nextjs/server';\n\nexport const submitOrder = wrapServerAction(async (input: OrderInput) => {\n  const order = await createOrder(input);\n  if (!order.eligible) throw new Error('Customer ineligible'); // captured\n  redirect(`/orders/${order.id}`); // NOT captured (Next control flow)\n});\n```\n\nThe wrapper detects Next's `redirect()` and `notFound()` control-flow throws (their\n`digest` strings start with `NEXT_REDIRECT` / `NEXT_NOT_FOUND`) and lets them propagate\nsilently — otherwise every redirect from a server action would land in your issue\ntracker. Real errors still get captured.\n\n## Pages Router: API routes\n\n```ts\nimport { wrapApiHandler } from '@arguslog/sdk-nextjs/server';\nimport type { NextApiRequest, NextApiResponse } from 'next';\n\nexport default wrapApiHandler(async (req: NextApiRequest, res: NextApiResponse) => {\n  const result = await fetchData(req.query.id as string);\n  res.json(result);\n});\n```\n\nSame shape as `wrapRouteHandler` but tagged as `route: 'pages'` so you can filter App\nRouter vs Pages Router issues separately.\n\n## Client: capturing component errors\n\nThe `client` subpath re-exports the React SDK so you don't have to install it separately:\n\n```tsx\n'use client';\n\nimport { ArguslogErrorBoundary, useArguslog } from '@arguslog/sdk-nextjs/client';\n\nexport function Checkout() {\n  const arguslog = useArguslog();\n\n  async function pay() {\n    try {\n      await charge();\n    } catch (err) {\n      arguslog.captureException(err, { tags: { feature: 'checkout' } });\n    }\n  }\n\n  return (\n    <ArguslogErrorBoundary fallback={<p>Something went wrong.</p>}>\n      <button onClick={pay}>Pay now</button>\n    </ArguslogErrorBoundary>\n  );\n}\n```\n\nInitialise the client SDK once — typically inside your root layout or a top-level client\ncomponent. The cleanest pattern is a tiny `Providers` client component:\n\n```tsx\n// app/providers.tsx\n'use client';\n\nimport { useEffect } from 'react';\nimport { init } from '@arguslog/sdk-nextjs/client';\n\nexport function Providers({ children }: { children: React.ReactNode }) {\n  useEffect(() => {\n    init({\n      dsn: process.env.NEXT_PUBLIC_ARGUSLOG_DSN!,\n      release: process.env.NEXT_PUBLIC_RELEASE,\n      environment: process.env.NODE_ENV,\n      integrations: ['globalHandlers', 'autoBreadcrumbs'],\n    });\n  }, []);\n\n  return <>{children}</>;\n}\n```\n\n```tsx\n// app/layout.tsx\nimport { Providers } from './providers';\n\nexport default function RootLayout({ children }: { children: React.ReactNode }) {\n  return (\n    <html lang=\"en\">\n      <body>\n        <Providers>{children}</Providers>\n      </body>\n    </html>\n  );\n}\n```\n\nNotice the env var is `NEXT_PUBLIC_…` — the client SDK runs in the browser, so the DSN\nneeds to be inlined into the bundle. The DSN's `publicKey` is project-scoped and safe\nto expose; rotate it from the Arguslog dashboard if it ever leaks.\n\n## Sourcemap upload\n\nProduction stack traces are useless without sourcemaps. The release flow is the same as\nany other Node/JS app:\n\n```bash\n# In your CI release pipeline, after `next build`:\narguslog releases new \"$RELEASE\" --project 42\nRELEASE_ID=$(arguslog releases new \"$RELEASE\" --project 42 | sed -nE 's/^release #([0-9]+).*/\\1/p')\n\n# Server bundles\nfor map in .next/server/**/*.js.map; do\n  arguslog sourcemaps upload \"$map\" --project 42 --release \"$RELEASE_ID\" --name \"${map%.map}\"\ndone\n\n# Client bundles\nfor map in .next/static/chunks/**/*.js.map; do\n  arguslog sourcemaps upload \"$map\" --project 42 --release \"$RELEASE_ID\" --name \"${map%.map}\"\ndone\n```\n\nSee the [`@arguslog/cli`](https://www.npmjs.com/package/@arguslog/cli) README for the\nfull GitHub Actions workflow.\n\n`next.config.js` must enable production sourcemaps so they exist to upload:\n\n```js\nmodule.exports = {\n  productionBrowserSourceMaps: true,\n};\n```\n\nThe `release` you pass to client `init()` and server `init()` must match the `<version>`\npassed to `arguslog releases new` — exact string match.\n\n## API reference\n\n### `@arguslog/sdk-nextjs/server`\n\n| Export                | Kind | Purpose                                                                              |\n| --------------------- | ---- | ------------------------------------------------------------------------------------ |\n| `init(options)`       | fn   | Re-export of `@arguslog/sdk-node` `init`. Call from `instrumentation.ts`.            |\n| `onRequestError`      | fn   | Drop-in for `Instrumentation.onRequestError` in Next.js 15.                          |\n| `wrapRouteHandler`    | fn   | App Router `app/.../route.ts` wrapper. Capture-and-rethrow.                          |\n| `wrapApiHandler`      | fn   | Pages Router `pages/api/*.ts` wrapper. Same shape, different route tag.              |\n| `wrapServerAction`    | fn   | `'use server'` wrapper that lets `redirect()`/`notFound()` propagate.                |\n| Capture API           | fn   | `captureException`, `captureMessage`, `setUser`, `setTag`, `addBreadcrumb`, `flush`. |\n| `runWithRequestScope` | fn   | Manual scope wrapper for non-route work (cron, queue workers).                       |\n| `ErrorContext`        | type | Local copy of Next's `Instrumentation.onRequestError` ctx shape.                     |\n| `RequestInfo`         | type | Local copy of Next's request info shape.                                             |\n\n### `@arguslog/sdk-nextjs/client`\n\n| Export                  | Kind      | Purpose                                                                              |\n| ----------------------- | --------- | ------------------------------------------------------------------------------------ |\n| `init(options)`         | fn        | Re-export of `@arguslog/sdk-react` `init`. Call once from a client comp.             |\n| `ArguslogErrorBoundary` | component | React error boundary that captures + renders a fallback.                             |\n| `useArguslog()`         | hook      | Returns the client wrapper for capture/scope mutations.                              |\n| Capture API             | fn        | `captureException`, `captureMessage`, `setUser`, `setTag`, `addBreadcrumb`, `flush`. |\n\n## Edge runtime\n\nFor routes you've forced onto the Edge runtime (`export const runtime = 'edge'`), the\nNode SDK won't load — its dependencies on `node:async_hooks`, `node:http`, etc. would\ncrash on load. Use only the client-style capture API in Edge code, or skip capture there\nand rely on `onRequestError` from `instrumentation.ts` (which Next routes to the Node\nruntime regardless).\n\n## Environment variables\n\n| Variable                          | Where  | Purpose                                                     |\n| --------------------------------- | ------ | ----------------------------------------------------------- |\n| `ARGUSLOG_DSN`                    | server | DSN for the server SDK. Server-only, never in bundles.      |\n| `NEXT_PUBLIC_ARGUSLOG_DSN`        | client | DSN inlined into the browser bundle.                        |\n| `RELEASE` / `NEXT_PUBLIC_RELEASE` | both   | Release tag. Must match what you uploaded sourcemaps under. |\n| `ARGUSLOG_TOKEN`                  | CI     | Personal access token for the CLI (releases + sourcemaps).  |\n\n## Troubleshooting\n\n**`Module not found: Can't resolve 'node:http'` in Edge build.**\nYou imported from `@arguslog/sdk-nextjs/server` in a route that runs on the Edge runtime.\nMove the import inside a `if (process.env.NEXT_RUNTIME === 'nodejs')` branch, or use\nthe client subpath instead.\n\n**`onRequestError` fires but no event lands on the dashboard.**\nThe instrumentation file has its own bundle context — `init()` may not have run yet, or\nran in a different worker. Make sure `register()` does the `init` call (not the module\ntop level) and that you're not gating it behind `if (process.env.NODE_ENV === 'production')`\nduring local debugging.\n\n**Server actions wrapped in `wrapServerAction` still log redirects.**\nDouble-check the imported symbol — only `wrapServerAction` understands the\n`NEXT_REDIRECT` digest. Using `wrapRouteHandler` for a server action will log every\nredirect.\n\n**Stack traces show minified `chunks/abc123.js` paths.**\nSet `productionBrowserSourceMaps: true` in `next.config.js`, run a fresh build, then\nupload the `.map` files with the CLI. Next emits client maps under `.next/static/` and\nserver maps under `.next/server/`.\n\n**The Edge runtime doesn't capture errors.**\nCapture in Edge has to go through `instrumentation.ts onRequestError` because the Node\nSDK doesn't run there. There's no in-Edge `init()` story today.\n\n## Source\n\nThe full implementation lives in the [arguslog monorepo](https://github.com/petarnenov/arguslog)\nat `packages/sdk-nextjs/`. Issues and PRs welcome.\n","readmeFilename":"README.md","homepage":"https://arguslog.org","repository":{"type":"git","url":"git+https://github.com/petarnenov/arguslog-sdks.git","directory":"packages/sdk-nextjs"},"bugs":{"url":"https://github.com/petarnenov/arguslog-sdks/issues"}}