
Research
SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.
@neondatabase/auth
Advanced tools
TypeScript SDK for Neon Auth - authentication for PostgreSQL with multiple adapter support
Authentication adapters for Neon Auth, supporting multiple auth providers.
@neondatabase/auth provides authentication for applications using Neon Auth. By default, it uses the Better Auth API, with optional adapters for different API styles:
signIn.email, signUp.email, etc.)signInWithPassword, signUp, etc.)useSession)This package is designed to work seamlessly with Neon's authentication infrastructure while providing:
@neondatabase/auth is a wrapper around Better Auth that provides:
API Flexibility:
Neon Auth Integration:
token_verifier on OAuth callbackBuilt-in Enhancements:
If you're not using Neon Auth, you should probably use better-auth/client directly for more flexibility.
npm install @neondatabase/auth
# or
bun add @neondatabase/auth
The createAuthClient factory function creates an auth client. By default, it uses the Better Auth API:
import { createAuthClient } from '@neondatabase/auth';
const auth = createAuthClient('https://your-auth-server.com');
// Sign up
await auth.signUp.email({
email: 'user@example.com',
password: 'secure-password',
name: 'John Doe',
});
// Sign in
await auth.signIn.email({
email: 'user@example.com',
password: 'secure-password',
});
// Get session
const session = await auth.getSession();
// Sign out
await auth.signOut();
import { createAuthClient } from '@neondatabase/auth';
const auth = createAuthClient('https://your-auth-server.com');
await auth.signIn.social({
provider: 'google',
callbackURL: '/dashboard',
});
You can optionally specify an adapter to change the API style. This is useful for migrations or if you prefer a different API.
Use this adapter if you're migrating from Supabase or prefer the Supabase API style:
import { createAuthClient, SupabaseAuthAdapter } from '@neondatabase/auth';
const auth = createAuthClient('https://your-auth-server.com', {
adapter: SupabaseAuthAdapter(),
});
// Supabase-compatible methods
await auth.signUp({
email: 'user@example.com',
password: 'secure-password',
options: {
data: { name: 'John Doe' },
},
});
await auth.signInWithPassword({
email: 'user@example.com',
password: 'secure-password',
});
const { data: session } = await auth.getSession();
await auth.signOut();
// OAuth with Supabase-style API
await auth.signInWithOAuth({
provider: 'google',
options: {
redirectTo: '/dashboard',
},
});
Use this adapter in React applications to get access to hooks like useSession:
import { createAuthClient } from '@neondatabase/auth';
import { BetterAuthReactAdapter } from '@neondatabase/auth/react/adapters';
const auth = createAuthClient('https://your-auth-server.com', {
adapter: BetterAuthReactAdapter(),
});
// Same API as default
await auth.signIn.email({
email: 'user@example.com',
password: 'secure-password',
});
// Plus React hooks
function MyComponent() {
const session = auth.useSession();
if (session.isPending) return <div>Loading...</div>;
if (!session.data) return <div>Not logged in</div>;
return <div>Hello, {session.data.user.name}</div>;
}
Enable allowAnonymous to let unauthenticated users access data via RLS policies:
import { createAuthClient } from '@neondatabase/auth';
const auth = createAuthClient('https://your-auth-server.com', {
allowAnonymous: true, // Enable anonymous data access
});
// Get token - returns anonymous token if no user session exists
const token = await auth.getJWTToken?.();
This is useful when you want to allow read-only public access to certain data while still enforcing RLS policies.
Factory function to create an auth client.
Parameters:
url - The auth service URL (required)config.adapter - Optional adapter factory function (e.g., SupabaseAuthAdapter())config.allowAnonymous - When true, returns an anonymous token if no user session exists (default: false)Returns: The adapter's public API (varies by adapter type)
signIn.email(credentials) - Sign in with emailsignIn.social(options) - Sign in with OAuthsignUp.email(credentials) - Create new usersignOut() - Sign out current usergetSession() - Get current sessionProvides a Supabase-compatible API:
signUp(credentials) - Create a new usersignInWithPassword(credentials) - Sign in with email/passwordsignInWithOAuth(options) - Sign in with OAuth providersignOut() - Sign out current usergetSession() - Get current sessiongetUser() - Get current userupdateUser(attributes) - Update user metadatagetUserIdentities() - Get linked OAuth identitieslinkIdentity(credentials) - Link OAuth providerunlinkIdentity(identity) - Unlink OAuth providerresetPasswordForEmail(email, options) - Send password resetonAuthStateChange(callback) - Listen to auth state changesSame as default API, plus:
useSession() - React hook for session stateSessions are cached in memory with intelligent TTL management:
exp claimMultiple concurrent getSession() calls are automatically deduplicated:
For Next.js projects, this package provides built-in integration via @neondatabase/auth/next.
See the Next.js Setup Guide for comprehensive documentation including:
createNeonAuth() for handler, middleware and api methodscreateAuthClient() for client componentsNeonAuthUIProvider with Email OTP, Social Login, and OrganizationsAuthView, AccountView, OrganizationView)authClient.useSession() hook in client componentsPre-built login forms and auth pages are included. No extra installation needed.
Without Tailwind CSS:
import '@neondatabase/auth/ui/css';
With Tailwind CSS v4:
@import 'tailwindcss';
@import '@neondatabase/auth/ui/tailwind';
"use client"
import { NeonAuthUIProvider } from "@neondatabase/auth/react/ui"
import { createAuthClient } from "@neondatabase/auth"
import "@neondatabase/auth/ui/css"
const authClient = createAuthClient('https://your-auth-url.com')
export function AuthProvider({ children }) {
return (
<NeonAuthUIProvider authClient={authClient} redirectTo="/dashboard">
{children}
</NeonAuthUIProvider>
)
}
Option A: Full Auth Pages (Recommended)
Use AuthView to render complete auth flows based on the URL path:
import { AuthView } from "@neondatabase/auth/react/ui"
// Renders sign-in, sign-up, forgot-password, etc. based on path
<AuthView path="sign-in" />
Option B: Individual Components
import { SignInForm, UserButton } from "@neondatabase/auth/react/ui"
<SignInForm />
<UserButton />
Available components: SignInForm, SignUpForm, UserButton, AuthView, AccountView, OrganizationView
For Next.js with dynamic routes, see the Next.js Setup Guide.
For full documentation and theming, see @neondatabase/auth-ui.
@neondatabase/neon-js - Full SDK with database and auth integration@neondatabase/postgrest-js - PostgREST client without authApache-2.0
FAQs
TypeScript SDK for Neon Auth - authentication for PostgreSQL with multiple adapter support
We found that @neondatabase/auth demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.

Company News
Socket is proud to join the OpenJS Foundation as a Silver Member, deepening our commitment to the long-term health and security of the JavaScript ecosystem.

Security News
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.