Meet the New Neon Auth: Branchable Identity in Your Database
Neon Auth has been rebuilt on Better Auth and now stores users, sessions, organizations and auth configuration in a neon_auth schema inside the Neon Postgres database. This replaces the earlier external-provider setup that relied on webhook sync. Because identity lives in the database, auth state clones with every branch, and each branch gets its own isolated auth endpoint co-located with compute. RLS policies can reference the JWT user, and user creation plus role assignment can happen in one transaction. A unified neon-js SDK ties together Auth, the Data API and the database, though Neon Auth does not yet support custom Better Auth plugins or server-side handlers.
Related posts
- Handling Auth in a Staging Environment
Neon mediumAdept
Neon Auth stores users, sessions and OAuth data in a neon_auth schema inside the Postgres database, so branching the database also branches auth state via copy-on-write. Each branch gets its own auth endpoint, which lets preview and staging environments test role, permission and OAuth changes against a copy of production users without touching production or creating test accounts by hand. Deleting the branch removes all copied users. It is built on Better Auth, used through the @neondatabase/neon-js SDK, and can be provisioned per PR with a GitHub Action that outputs the branch's auth URL.
- A Simple 3-Step Process to Migrate from Supabase Auth to Neon Auth
Neon mediumAdept
Supabase Auth users can be moved to Neon Auth (built on Stack Auth) without forcing password resets by exporting bcrypt hashes in Modular Crypt Format and importing them through the Stack Auth REST API. A PL/pgSQL function joins auth.users and auth.identities to export emails and encrypted passwords to CSV. A Node.js script then posts each user to the create-users endpoint with the hash in password_hash, handling UTF-8 BOMs and throttling requests to avoid rate limits. Imported users appear in a read-only neon_auth.users_sync Postgres table that can be joined in application queries.
- Stop Mocking Auth (It’s Breaking Your Tests)
Neon mediumAdept
Mocking authentication in tests hides real failures: password hashing and verification, UNIQUE-constraint enforcement under concurrent signups, session handling, and SQL joins between auth and application data. Neon Auth stores users, sessions and tokens in a neon_auth Postgres schema, so a copy-on-write database branch (created in about a second) also branches auth with its own isolated Auth URL. A GitHub Actions workflow can create a branch per pull request, run tests against real auth and data, then delete the branch, giving isolation without mocks or shared staging databases.
- Database-per-User Architecture With Shared Application Environments: How and Why
Neon mediumAdept
A single shared application environment serving many per-customer Neon Postgres databases keeps deployment simple, but every tenant database must stay at the same schema version and data residency is hard to offer. Tenant identification can come from a login field, a per-customer subdomain, or a lookup from the user's credentials. A catalog database maps users or JWT-carried customer IDs to Neon project IDs for connection routing, and it also holds tier and feature-flag context. Schema changes need either slow, backward-compatible rollouts using views and triggers, or pre-upgrade testing of each tenant database on branches. The control plane should be kept separate from the app so failures don't take both down.
- Inside LuBot's database-per-tenant architecture
Neon mediumAdept
LuBot, a solo-founder analytics chat product, gives each paying customer an isolated Postgres database by creating a Neon branch from a Stripe webhook, with Supabase kept as the control plane for orgs, users and billing. Branches get deterministic names so webhook retries are idempotent; the new branch is migrated, its connection URL is stored on the user row, and all access goes through a single tenant resolver function. Tenant computes autoscale from 0.25 to 4 CU and suspend after 300 seconds idle, avoiding roughly $20/month per idle tenant. Behind PgBouncer transaction-mode pooling, session settings like search_path do not persist, so set them per query or at the role level, use direct URLs for migrations, and reset connections on check-in.