sentry-nextjs-sdk

Configure Sentry error monitoring, tracing, and session replay for Next.js applications.

Updated Apr 22, 2026
One-click install
npx skills add https://github.com/imrishuroy/algopatterns --skill sentry-nextjs-sdk-imrishuroy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sentry-nextjs-sdk
Source: https://github.com/imrishuroy/algopatterns/tree/main/.agents/skills/sentry-nextjs-sdk
Command: npx skills add https://github.com/imrishuroy/algopatterns --skill sentry-nextjs-sdk-imrishuroy

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @sentry/nextjs, and includes references (resource) components.

What problem does it solve? Setting up Sentry in a Next.js app requires configuring three separate runtimes (browser, Node.js server, and Edge), wiring instrumentation hooks, error boundaries, and source map uploads. This Skill guides you through the entire setup so nothing is missed. ## Core Features & Use Cases - Three-Runtime Setup: Creates instrumentation-client.ts, sentry.server.config.ts, sentry.edge.config.ts, and instrumentation.ts with correct runtime dispatch. - Feature Configuration: Step-by-step references for error monitoring, tracing, session replay, logging, profiling, AI monitoring, crons, and metrics. - Router-Aware Guidance: Handles both App Router (global-error.tsx) and Pages Router (_error.tsx) patterns, plus Turbopack vs webpack differences. - Use Case: You have a Next.js 15 app with App Router and a Go backend. The Skill detects your stack, recommends Error Monitoring + Tracing + Session Replay, generates all config files, and suggests the matching Go SDK skill for distributed tracing. ## Quick Start Ask the AI to add Sentry to your Next.js app and set up error monitoring, tracing, and session replay across all runtimes.

Frequently Asked Questions about sentry-nextjs-sdk

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add Sentry to a Next.js app?

Run npx @sentry/wizard@latest -i nextjs for automated setup, or manually install @sentry/nextjs and create instrumentation-client.ts, sentry.server.config.ts, sentry.edge.config.ts, and instrumentation.ts. Then wrap next.config with withSentryConfig.

How do I capture errors in Next.js App Router error boundaries?

Next.js catches errors in error.tsx and global-error.tsx before Sentry sees them, so you must call Sentry.captureException(error) inside a useEffect in those files. Unhandled errors outside boundaries are captured automatically.

Does @sentry/nextjs support both App Router and Pages Router?

Yes, both routers are supported on Next.js 13+. App Router uses global-error.tsx for root errors, while Pages Router uses pages/_error.tsx with captureUnderscoreErrorException. Note that automaticVercelMonitors only works with Pages Router.

Why are my Sentry stack traces showing minified code?

Source maps are not being uploaded during the build. Set SENTRY_AUTH_TOKEN as a build-time secret and configure authToken plus widenClientFileUpload in withSentryConfig, then run next build and check for source map upload output.

Why are my Server Component errors not appearing in Sentry?

You need to export onRequestError from instrumentation.ts using Sentry.captureRequestError. This requires @sentry/nextjs version 8.28.0 or higher and Next.js 15 or later.

Does Sentry tracing work with Turbopack in Next.js?

Tracing works, but the webpack.treeshake options in withSentryConfig only apply to webpack builds. Remove tree-shaking options when using Turbopack, which requires Next.js 15 or later for Sentry support.