Sentry captures unhandled exceptions, groups identical errors from different users into a single issue, and provides the breadcrumbs, context, and session replay you need to reproduce and fix bugs without asking users what they did. It is the most widely used error tracking tool for production web applications, and it works.
What Sentry Captures That Plain Logging Does Not
The problem with console.log and log aggregators (Datadog Logs, Papertrail, Logtail) is that they give you raw text. When an error happens 1,000 times from 1,000 different users, you get 1,000 log lines. Finding the unique errors, understanding which users are affected, and reproducing the conditions requires manual work.
Sentry solves this with automatic error grouping. When the same exception (same stack trace, same error message) occurs 1,000 times, Sentry shows you one issue with a count of 1,000 occurrences. You see the error once, fix it once, and mark it resolved.
Beyond grouping, Sentry captures:
Breadcrumbs: automatic log of what happened before the error. Sentry automatically captures console logs, HTTP requests, navigation events, user interactions, and database queries that occurred in the 30 seconds before the error. When you look at an issue, you see a timeline of exactly what the user did and what your app called before it crashed.
Context: browser, OS, screen resolution, user identity, and any custom context you set. Knowing that an error only happens on Safari 17 on iOS 16 changes your debugging approach entirely.
Session replay (Sentry Replay): optional video-like recording of the user's screen session before the error. Watch exactly what the user did, including clicks, scrolls, and input events, in a privacy-respecting way (sensitive data is masked by default). This is the most powerful debugging tool Sentry offers: often you can watch a 30-second replay and immediately understand what caused the error.
Setting Up Sentry in Next.js
Install the Sentry Next.js SDK:
pnpm add @sentry/nextjs
Run the Sentry wizard for automatic setup:
npx @sentry/wizard@latest -i nextjs
The wizard creates sentry.client.config.ts, sentry.server.config.ts, and sentry.edge.config.ts, and updates next.config.ts to enable source map upload during builds.
Minimal configuration:
// sentry.client.config.ts
import * as Sentry from '@sentry/nextjs'
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
tracesSampleRate: 0.1, // capture 10% of transactions for performance monitoring
replaysSessionSampleRate: 0.01, // capture 1% of sessions
replaysOnErrorSampleRate: 1.0, // always capture replay when an error occurs
integrations: [Sentry.replayIntegration()],
})
Set the DSN in your environment:
NEXT_PUBLIC_SENTRY_DSN=https://...@sentry.io/...
SENTRY_AUTH_TOKEN=... # for source map upload during build
Source Maps: Making Stack Traces Readable
Without source maps, Sentry shows you minified JavaScript stack traces: at t (main.js:1:234567). With source maps, you see the original TypeScript: at handlePayment (src/lib/payments/stripe.ts:42:8). This is the difference between being able to debug in 5 minutes versus spending an hour.
The Sentry Next.js wizard configures source map upload automatically using the SENTRY_AUTH_TOKEN. During next build, source maps are uploaded to Sentry and then deleted from the production bundle (so your source code is not exposed to users).
Error Boundaries for React
React errors inside components do not propagate to the global error handler by default. They crash the component tree silently. Add Sentry error boundaries to catch React rendering errors:
import * as Sentry from '@sentry/nextjs'
export default function RootLayout({ children }) {
return (
<html>
<body>
<Sentry.ErrorBoundary fallback={<p>Something went wrong.</p>}>
{children}
</Sentry.ErrorBoundary>
</body>
</html>
)
}
Identifying Users in Errors
When an error occurs, you want to know which user was affected. Set the user context after authentication:
Sentry.setUser({ id: user.id, email: user.email, name: user.name })
Call this after the user logs in. Now every error captured includes the user's identity, and you can search Sentry issues by affected user or see how many unique users are affected by a given bug.
Performance Monitoring
Sentry Performance tracks frontend and backend transaction traces: how long individual pages, API routes, and database queries take. This is separate from error tracking but uses the same SDK.
When performance monitoring is enabled, Sentry shows you:
- Slow transactions: which pages and API routes are slowest
- Database query performance: slow queries (requires SDK integration with your ORM or database driver)
- N+1 detection: Sentry identifies when your code makes the same query many times in a loop
The tracesSampleRate controls what percentage of requests are traced. Start with 0.1 (10%) in production to manage volume.
Sentry vs Alternatives
Bugsnag: similar feature set to Sentry, slightly different pricing model (by MAU rather than event volume). Better for mobile app error tracking.
Rollbar: older Sentry competitor, less commonly used in new projects, has a solid feature set.
LogRocket: focused on session replay rather than error tracking. Better replay quality than Sentry Replay, but error tracking is secondary. Use LogRocket if session replay is your primary need.
Self-hosted Sentry: Sentry is open source and can be self-hosted. The self-hosted version lags behind Sentry SaaS on features but is free beyond server costs. Suitable for organizations with data residency requirements.
Pricing
The free tier includes 5,000 errors per month, 10,000 performance transactions, 50 session replays, and 1 team member. For side projects and small apps, this is often enough.
The Team plan ($26/month for a team of 5) is the first paid tier: 50,000 errors, 100,000 performance transactions, unlimited replays. For most production applications, this is the right tier. It is worth it when you start getting real users: the time saved debugging a single production incident pays for months of Sentry.
Keep Reading
- Grafana and Prometheus Monitoring Guide — metrics monitoring that complements Sentry's error tracking
- GitHub Actions Guide for Developers — automating Sentry release tracking in your CI pipeline
- We Replaced 6 SaaS Tools With One: What Happened — evaluating which tools are worth the cost
Pristren builds AI-powered software for teams. Zlyqor is our all-in-one workspace — chat, projects, time tracking, AI meeting summaries, and invoicing — in one tool. Try it free.