Skip to content

0010. Authentication: Better Auth (self-hosted, Postgres)

  • Status: Accepted
  • Date: 2026-11-26
  • Phase: 3

We need email + OAuth sign-in (Google, GitHub, Discord), sessions for the web app, API tokens for the SDK, and OAuth for remote MCP clients. It must run locally without a vendor account and keep user data in our database.

Use Better Auth (TypeScript, Drizzle/Postgres adapter) for sessions, OAuth providers, passkeys, email verification and organisation/role support. Add its OAuth-provider/MCP plugin (or a small OAuth 2.1 authorization server) for remote MCP clients in Phase 3. Personal access tokens for the SDK and CLI.

  • Amazon Cognito: managed, cheap at scale, AWS-native; awkward local development and customization, lock-in.
  • Auth.js: widely used but its non-Next.js story and maintenance direction are less certain.
  • Clerk / Auth0 / WorkOS: fast to integrate, polished UI; per-MAU cost that hurts at 1M players; vendor holds users.
  • Supabase Auth: good, but couples us to Supabase.
  • Roll our own: no.

We own security patching (keep Better Auth updated; it is a dependency on the critical path). Players who only play do not need accounts; accounts are needed to create, publish, rate, or save to the cloud.