nextjs-zenstack-auth-context-error
Installation
SKILL.md
Next.js + ZenStack Auth Context Error Fix
Problem
In Next.js production builds, manually creating ZenStack auth contexts with db.$setAuth()
can cause type mismatches that manifest as generic Server Components render errors. The
actual error details are hidden in production for security, making debugging extremely
difficult.
Context / Trigger Conditions
When this occurs:
- Next.js app in production shows generic error page
- Sentry/error tracking shows: "An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details."
- Same code works perfectly in development environment
- Using ZenStack ORM with Better Auth
- Using Server Components or Server Actions with database queries