Claude Code Boilerplate
FeaturesPricingBlogDocs
Get started →

Product

  • Features
  • Pricing
  • Skills

Compare

  • vs ShipFast
  • vs MakerKit
  • vs supastarter

Resources

  • Docs
  • Blog
  • Discord

Legal

  • License
  • Privacy Policy
  • Terms of Service
Claude Code Boilerplate

© 2026 Claude Code Boilerplate. All rights reserved.

← All posts

Error Monitoring in Your Next.js SaaS -- Know When Something Breaks Before Your Users Do

August 7, 2026
nextjssaasdrizzle-ormresendmonitoring

You find out your payment flow is broken when a customer emails: "I tried to upgrade but it keeps failing." The feature stopped working two days ago.

That is the most common production bug story in early-stage SaaS -- not the crash, but the delay. By the time you know something is broken, you have already lost trust and probably a customer.

Error monitoring closes that gap. Here is how to add it to your Next.js SaaS boilerplate without signing up for another $26-per-month tool.

Why Most Early-Stage Products Skip This (and Regret It)

Sentry is the go-to recommendation, and its free tier covers most early products. But many founders skip it because it feels like one more thing to set up before they can ship.

The result: they go live with zero visibility into what breaks. When something goes wrong, they are the last to know.

The good news: if you already have Drizzle ORM, Resend, and a Next.js API route, you have everything you need to build a basic error monitoring layer that alerts you the moment something fails.

Three Levels of Visibility -- Pick Where You Are

Before picking a solution, decide what level of visibility you need right now:

  • Level 1 -- Email alerts: catch critical errors and email yourself immediately. Works for MVPs. Takes 30 minutes to set up.
  • Level 2 -- Error log in the database: store errors with context (user, route, message, stack trace) so you can search and filter. Takes a few hours.
  • Level 3 -- Full observability: session replay, performance metrics, sourcemaps. Use Sentry or Highlight.io free tier. Overkill before your first 100 users.

Most founders need Level 1 on launch day, Level 2 by the time they have paying customers, and Level 3 only when debugging becomes a full-time job.

Level 1 -- Email Alerts in 30 Minutes

Your boilerplate already sends transactional email via Resend. You can reuse the same emailService to fire an alert whenever an unhandled error reaches your API routes.

Add a reportError helper in lib/errors/index.ts:

export async function reportError(error: unknown, context?: string) {
  if (process.env.NODE_ENV !== 'production') return;
  await emailService.sendEmail({
    to: process.env.ALERT_EMAIL!,
    subject: `[ERROR] ${context ?? 'Unhandled error'}`,
    react: React.createElement(ErrorAlertEmail, {
      message: error instanceof Error ? error.message : String(error),
      context,
      appName: 'Your SaaS',
    }),
  });
}

Call reportError(error, 'POST /api/payments') inside any catch block on a critical path. Set ALERT_EMAIL to your inbox. You will get an email within seconds of a failure -- before any user has time to write a complaint.

Level 2 -- A Searchable Error Log

When you have 20-30 users, a searchable error table beats an inbox full of alerts. Add a table to your Drizzle schema:

export const errorLogTable = pgTable('error_logs', {
  id: uuid('id').primaryKey().defaultRandom(),
  message: text('message').notNull(),
  stack: text('stack'),
  context: text('context'),
  userId: uuid('user_id').references(() => userTable.id),
  route: text('route'),
  createdAt: timestamp('created_at').defaultNow().notNull(),
});

Extend reportError to write a row before sending the email. Your admin panel (see how to build an admin panel) can then render a filterable error list. Three users hitting the same failure on the same route is a signal you need to act fast -- a single row in an email is easy to miss.

What Context to Capture

An error message alone is rarely enough to fix the bug. For every error, capture:

  • The route or service that threw the error
  • The authenticated user ID (if available)
  • The error message and stack trace
  • The exact timestamp

That combination lets you find the affected user, correlate with your audit log, reproduce the request, and push a fix the same day.

When to Upgrade to Sentry

Reach for Sentry or Highlight.io when:

  • You have 50+ active users and error emails arrive faster than you can read them
  • You need source maps to decode minified stack traces in production
  • You want session replay to see exactly what a user did before the crash

Both have free tiers generous enough for an early-stage SaaS. Setup is one environment variable and a Next.js instrumentation file -- you do not need to rewrite your error-handling logic.

Your Pre-Launch Checklist

Before you go live:

  • ALERT_EMAIL set in environment variables
  • reportError() called in every catch block on auth, payment, and data-write paths
  • error_logs table migrated to your Neon database
  • Admin panel shows recent errors filtered by route and user

After your first 50 users:

  • Sentry or Highlight.io connected with an API key
  • Source maps uploaded on every Vercel deploy
  • Slack or email digest for new production errors

Start With What You Already Have

You do not need a new tool to catch production failures. The Next.js SaaS boilerplate already includes Resend for email and Drizzle ORM for the database -- wire them together and you have real-time alerts before your first paying customer signs up.

Add the full observability layer when your user count makes it worth it. For now, knowing within five minutes that something broke is all you need.

Get the boilerplate and ship with visibility from day one: boilerplate.iteam-company.com