Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Auth.js · Const

NeonAdapter

NeonAdapter connects Auth.js to Neon PostgreSQL through a Neon serverless Pool. Pass the Pool to Auth.js as its database adapter.

How it works

NeonAdapter connects Auth.js to a Neon PostgreSQL database through a serverless Pool. Pass the Pool to the adapter in the Auth.js configuration so Auth.js can persist users, accounts, sessions, and verification data using its expected schema.

Syntax

NeonAdapter(client)

Parameters

NameTypeDescription
clientPoolNeon serverless PostgreSQL connection pool supplied to the adapter factory.

Returns

Adapter

Key points

  • NeonAdapter is Auth.js's official adapter for PostgreSQL databases hosted on Neon.
  • The package's default export is a factory function that converts a client into an Auth.js Adapter.
  • Import the default adapter from the @auth/neon-adapter package.
  • Use Pool from @neondatabase/serverless as the database client.
  • Register the constructed adapter in the Auth.js configuration through the adapter property.

Common mistakes

  • Create the pool inside the request handler rather than at module scope when using the shown Next.js setup.
  • Apply the adapter's documented SQL schema to the Neon database before relying on database-backed authentication.

Example: Configure Auth.js with Neon

import NextAuth from "next-auth"
import NeonAdapter from "@auth/neon-adapter"
import { Pool } from "@neondatabase/serverless"

export const { handlers, auth, signIn, signOut } = NextAuth(() => {
  const pool = new Pool({ connectionString: process.env.DATABASE_URL })
  return {
    adapter: NeonAdapter(pool),
    providers: [],
  }
})

Creates a Neon connection pool inside the request-time Auth.js configuration and passes it to the adapter.

When to use it

Database-backed authentication

Persisting Auth.js users, linked provider accounts, sessions, and verification records in Neon PostgreSQL.

Serverless Neon integration

Running Auth.js with Neon PostgreSQL in a serverless or edge-oriented deployment.

Official PostgreSQL adapter

Using the standard Auth.js database model with a Neon-hosted PostgreSQL backend.

Interview questions

QWhat does NeonAdapter do?

NeonAdapter is the official PostgreSQL adapter for Auth.js and accepts a Neon serverless Pool. It returns an Auth.js Adapter that supplies the database operations required by authentication.

Follow-up: What must the database provide? It must contain the tables and columns described by the adapter's SQL schema so those operations can persist Auth.js data.

QWhat is the function signature and return type?

The adapter factory is called with a Pool: NeonAdapter(pool). The API reference specifies that its parameter is a Pool and its return value is an Adapter.

Follow-up: Why use the Neon serverless Pool? It is the client type shown by the integration documentation for connecting Auth.js to Neon PostgreSQL in serverless environments.

QWhere should the Pool be created?

In the documented Next.js configuration, the Pool is constructed inside the function supplied to NextAuth, not at module scope. This keeps connection creation within the request-time handler pattern shown by the page.

Follow-up: Would the same placement rule necessarily apply to every framework example? No: the page's Express example constructs the Pool at module scope, so follow the placement shown for the target framework.

  • Pool
  • Adapter
  • @auth/neon-adapter
  • @neondatabase/serverless
  • NextAuth

Source: Neon Adapter. Checked 2026-10-15.