Skip to content
Home / Migrations / NextAuth.js / Auth.jsBetter Auth

NextAuth.js / Auth.js Better Auth

medium

Better Auth is framework-agnostic, plugin-based, and offers full type safety end-to-end. NextAuth's complexity around adapters and callbacks goes away.

Estimated: 3-6h · 5 steps
Progress0%
Step 1: Install Better Auth
npm uninstall next-auth @auth/* && npm install better-auth
Step 2: Create auth instance

Replace [...nextauth]/route.ts with a single auth.ts.

import { betterAuth } from 'better-auth'
import { drizzleAdapter } from 'better-auth/adapters/drizzle'
export const auth = betterAuth({ database: drizzleAdapter(db), emailAndPassword: { enabled: true } })
Step 3: Mount API handler

Create app/api/auth/[...all]/route.ts with auth.handler.

import { auth } from '@/auth'
export const { GET, POST } = auth.handler
Step 4: Migrate session usage

useSession() / getServerSession() → auth.api.getSession({ headers }) on server, authClient.useSession() on client.

Step 5: Add OAuth providers

socialProviders: { github: { clientId, clientSecret } } — config moves into the betterAuth() call.

Sign-in flow works for email/password and OAuth. Sessions persist across reloads.

What this migration involves

Moving from NextAuth.js / Auth.js to Better Auth is rated medium and takes about 3-6h on a typical project. The guide breaks it into 5 steps, 3 of which ship with runnable commands and 1 with a verification check.

FAQ

How long does migrating from NextAuth.js / Auth.js to Better Auth take?

Around 3-6h for a typical project — 5 steps, difficulty rated medium, 3 of them with copy-paste commands.

Is moving from NextAuth.js / Auth.js to Better Auth reversible?

No reverse guide is tracked yet, so treat this as a one-way move and keep a full export of your NextAuth.js / Auth.js data before you start.

What does Better Auth cost compared to NextAuth.js / Auth.js?

Better Auth: open-source from $0/mo, free plan available.