Better Auth - Next.js Showcase
A production-grade Next.js 15 authentication boilerplate that teaches modern auth patterns through a side-by-side client vs server contrast.
Didactic · 12-05-2026 · Next.js 15, React 19, TypeScript, better-auth, Prisma, Neon, PostgreSQL, OAuth2, GitHub OAuth, Google OAuth, Resend, Tailwind CSS v4, Server Actions, RSC, Edge Runtime, Turbopack, Vercel, MIT
Open source teaching boilerplate built end-to-end to make the tradeoffs between client-side and server-side authentication viscerally clear — two identical-looking dashboards, two completely different mechanics.
My Role
- Sole author: architecture, code, schema, deployment, and docs - Designed the pedagogical contrast: clientuseSession() + router.replace() vs server auth.api.getSession() + unauthorized() interrupt
- Wired Prisma to Neon via the HTTP adapter (@prisma/adapter-neon) for Edge/serverless compatibility
- Implemented email/password + GitHub + Google OAuth via better-auth
- Added Resend-backed email verification with autoSignInAfterVerification
- Patched React Server Components CVE vulnerabilities (security hardening pass)
- Authored CLAUDE.md + README.md + .env.template so anyone can clone, configure, and run
Technical Highlights
- Nomiddleware.ts by design — each protected route owns its session check, exposing the real cost/benefit tradeoff
- Catch-all auth route at /api/auth/[...all] handles every better-auth HTTP call in 4 lines
- experimental.authInterrupts enabled — unauthorized() throws a real HTTP 401 from RSC, renders app/unauthorized.tsx in place, preserves the URL, zero client flash
- Server Actions for sign-out, multi-session revoke, and profile updates with revalidatePath()
- Turbopack for both dev and build
- Prisma schema with cascading deletes, FK indexes, unique constraints on email + token
Challenges Solved
- Two routes that look identical but behave oppositely — kept both in sync visually via a sharedUnauthorizedScreen component
- Neon HTTP driver vs TCP pitfall: @prisma/client alone silently falls back to TCP and breaks in Edge runtimes — fixed by mandating the adapter in the singleton
- Resend sandbox gotcha: onboarding@resend.dev only delivers to the registered email — documented as a teaching point
- Session truth boundary: enforced "better-auth is the only source of session truth" — no localStorage drift, no spoofable client state
Expertise Shown
✅ Mastery of the Next.js 15 App Router — RSC, Server Actions, route interceptors,experimental.authInterrupts
✅ Deep understanding of auth tradeoffs: client hooks vs server session resolution, 200 vs 401, URL preservation, content leak windows
✅ Edge/serverless database patterns with Neon's HTTP driver + Prisma adapter
✅ Security awareness: CVE remediation, env validation, no client-side auth state
✅ Teaching through code: deliberate architectural contrasts, embedded docs, MIT-licensed reusable seedMore projects
- Ride Flumserberg — My Snowboard School and Booking Platform — My own snowboard school in the Swiss Alps, and the production booking platform I built for it: trilingual booking, Stripe + TWINT payments, admin and instructor panels.
- Better Auth - Next.js Showcase — A production-grade Next.js 15 authentication boilerplate that teaches modern auth patterns through a side-by-side client vs server contrast.
- Optimized Portfolio Website — This portfolio itself. The one you're watching right now
- Full Stack E-commerce Platform — Full-featured e-commerce platform with shopping cart and payment gateway integration.
- Custom AEM Integration for Telefónica — The full integration of Adobe's CMS across the entire Telefónica environment.
- Editable CMS based in NextJS — Next.js applications with built-in database editing capabilities in controlled environments (staging).
- Nextjs Ecosystem - Movistar Portal — The full integration of Adobe's CMS across the entire Telefónica environment.
- Customer Portal for Movistar Clients — The management portal for Movistar customers. Responsive and embedded within the MiMovistar application. And much more. See the details!
- Automating trading Algorithm. Moby Dick — Real-time Binance trading bot with trailing-stops, GCP infrastructure, BigQuery analytics, and Telegram monitoring
- Call Tracking System — Full‑stack development of a lead generation system based on call routing and call traceability.