Skip to main content
Neon Docs

Search documentation

Type to search this documentation.

On this pageOverview

Legacy Neon Auth with Stack Auth

This is the documentation for the previous Neon Auth implementation built with Stack Auth. It is no longer available for new projects but remains supported for existing users. For the current Managed ...

This is the documentation for the previous Neon Auth implementation built with Stack Auth. It is no longer available for new projects but remains supported for existing users.

For the current Managed Better Auth, see Managed Better Auth documentation. Ready to upgrade? See our migration guide.

Neon Auth brings authentication and user management natively to your database.

Neon Auth helps you move faster by handling the auth stack for you:

  • Add auth to your app in minutes: SDKs for Next.js and React
  • No more custom sync code: user profiles are always up-to-date in your database, ready for SQL joins and analytics.
  • Built-in support for teams, roles, and permissions.

When you set up Neon Auth, we create a neon_auth schema in your database. As users authenticate and manage their profiles in Neon Auth, you'll see them appear in your list of users on the Auth page.

Users in Neon Auth

User data is immediately available in your database

User data is available in the neon_auth.users_sync table shortly after the Neon Auth processes the updates. Here's an example query to inspect the synchronized data:

SQL
SELECT * FROM neon_auth.users_sync;
id name email created_at updated_at deleted_at raw_json
d37b6a30... Jordan Rivera jordan@company.co 2025-05-09 16:15:00 null null {\"id\": \"d37b6a30...\", ...}
51e491df... Sam Patel sam@startup.dev 2025-02-27 18:36:00 2025-02-27 18:36:00 null {\"id\": \"51e491df...\", ...}

The following columns are included in the neon_auth.users_sync table:

  • raw_json: Complete user profile as JSON
  • id: The unique ID of the user
  • name: The user's display name
  • email: The user's primary email
  • created_at: When the user signed up
  • deleted_at: When the user was deleted, if applicable (nullable)
  • updated_at: When the user was last updated, if applicable (nullable)

Updates to user profiles in Neon Auth are automatically reflected in your database.

Do not try to change the neon_auth.users_sync table name. It's needed for the synchronization process to work correctly.

For detailed integration patterns, foreign key examples, and best practices, see Database Integration.

To use Stack Auth with your Neon project, you need these environment variables:

Bash
NEXT_PUBLIC_STACK_PROJECT_ID=your-project-id
NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=your-client-key
STACK_SECRET_SERVER_KEY=your-server-secret

You can get these keys from the Neon Console Auth page, or by using the Neon API.

Generates SDK keys for your auth provider integration. These keys are used to set up your frontend and backend SDKs.

Required parameters:

  • project_id: Your Neon project ID
  • auth_provider: The authentication provider (currently "stack")
Bash
curl --request POST \
     --url 'https://console.neon.tech/api/v2/projects/auth/keys' \
     --header 'authorization: Bearer $NEON_API_KEY' \
     --header 'content-type: application/json' \
     --data '{
       "project_id": "project-id",
       "auth_provider": "stack"
     }' | jq

Example response:

JSON
{
  "auth_provider": "stack",
  "auth_provider_project_id": "project-id-123",
  "pub_client_key": "pck_example...",
  "secret_server_key": "ssk_example...",
  "jwks_url": "https://api.stack-auth.com/api/v1/projects/project-id-123/.well-known/jwks.json",
  "schema_name": "neon_auth",
  "table_name": "users_sync"
}

Try in API Reference ↗

Neon Auth is powered by Stack Auth under the hood. By default, Neon manages your authentication for you, so you do not typically need to interact with Stack Auth directly. However, there are cases where you may want to take direct control of your authentication project in the Stack Auth dashboard.

Most Neon Auth features can be built using the SDKs, without claiming your project.

Right now, you need to claim your project if you want to:

  • Add or manage OAuth providers (register client IDs/secrets, set callback URLs)
  • Enable production mode and enforce production security settings
  • Manage multiple projects or separate production and development environments directly in Stack Auth
  1. Claim via the Neon console

    1. Go to your project's Auth page, Configuration tab in the Neon Console.
    2. Click Claim project in the Claim project section.
    3. Follow the prompts to select the Stack Auth account that should receive ownership.

    After claiming, you'll have direct access to manage your project in the Stack Auth dashboard, while maintaining the integration with your Neon database.

    You can also find your current project ID here, as well as the JWKS URL you need to set up RLS in your Neon Auth project.

    Claim via the API

    You can also claim your project programmatically:

    Bash
    curl --request POST \
         --url 'https://console.neon.tech/api/v2/projects/auth/transfer_ownership' \
         --header 'authorization: Bearer $NEON_API_KEY' \
         --data '{
           "project_id": "project-id",
           "auth_provider": "stack"
         }'

    Open the returned URL in your browser to complete the claim process. See Neon Auth API Reference for more details.

    note

    After claiming, you'll still be able to access your project from the Neon Console, but you'll also have direct access from the Stack Auth dashboard.

Ready to upgrade to Managed Better Auth? See our comprehensive migration guide.

  • Native branching support - Auth branches automatically with your database
  • Simplified configuration - One URL instead of four keys
  • Direct database access - No webhooks, no sync delays
  • Open-source foundation - Built on Better Auth
  • Side-by-side code comparisons
  • Package and component replacements
  • Environment variable updates
  • Step-by-step instructions

View Migration Guide →

For SDK documentation, components, hooks, and client-side authentication:

Join our Discord Server to ask questions or see what others are doing with Neon. For paid plan support options, see Support.

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu