better-auth-context-performance

Installation
SKILL.md

Better Auth Context Performance Anti-Pattern

Problem

When using Better Auth v1.4.10+ with ZenStack ORM, manually creating auth contexts with db.$setAuth() bypasses the 15-minute JWE cookie cache, causing unnecessary database queries and 5x slower performance.

Context / Trigger Conditions

This anti-pattern appears when:

  • Server actions or components call db.$setAuth({ ...user, role: ... }) directly
  • Functions accept a User parameter only to create an auth context
  • Dashboard loads slowly (>500ms when should be <200ms)
  • Multiple components in same request create separate auth contexts
  • You see patterns like: const userDB = db.$setAuth(user)
Installs
1
GitHub Stars
1
First Seen
Mar 4, 2026
better-auth-context-performance — hankanman/claude-config