Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Neon 7 min read Announcement mediumAdept

Handling Auth in a Staging Environment

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.

Related posts

  • 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.

  • Meet the New Neon Auth: Branchable Identity in Your Database

    Neon easyNovice

    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.

  • Branching Postgres databases with the Neon API

    Neon mediumAdept

    Neon branches are copy-on-write clones of a Postgres database that can be created and deleted through the Neon API, giving CI pipelines an isolated copy of production data for end-to-end tests. Two experimental GitHub Actions, neondatabase/create-branch-action and neondatabase/delete-branch-action, wrap the API. A sample pull-request workflow creates a branch from a parent branch, runs the test steps, then deletes the branch. The actions were beta at the time and still being hardened for production use.

  • Adopting Neon branching in CI/CD pipelines: a practical story by Shepherd

    Neon mediumAdept

    Shepherd, an insurtech startup that moved its Alchemist pricing engine from SQLite to Postgres, uses Neon's copy-on-write database branches to give every pull request an ephemeral test database. GitHub Actions call the Neon API to create a branch when a PR opens and delete it on merge. Changes then flow from per-developer and per-PR branches to staging and production, with Render pre-deploy commands applying migrations tracked in a dedicated timestamped table. The team credits branching with removing the cost and effort of keeping test instances synced with production, and notes that scale-to-zero means it no longer pays for idle databases.

  • Behind Modem.dev’s Product Velocity

    Neon mediumAdept

    Modem, a startup building an AI agent that centralizes user feedback from Slack, Discord and GitHub, uses Neon Postgres branching as its development workflow. Every PR with a migration gets its own database branch, where the migration is applied and a schema diff is posted to the PR. The process is repeated against a fresh branch at merge time to catch conflicting migrations, and each Vercel preview runs on an ephemeral branch with automatic cleanup. Two practical tips: script branching through the Neon CLI so coding agents can drive it, and tag OAuth refresh tokens with the originating branch so preview environments can't invalidate production tokens.

The quest for software engineering knowledge.

Look:
Layout: