If your Auth.js setup is working well there is no urgent need to migrate.
Better Auth continues to add features previously exclusive to Auth.js, and we
welcome the opportunity to earn your adoption on new or greenfield projects.
1
Create the Better Auth instance
Follow the installation guide to add Better Auth to your
project. Here is a side-by-side comparison of a minimal GitHub OAuth config:
- Auth.js
- Better Auth
auth.ts
2
Create the client instance
Better Auth ships a separate client package for browser/React usage:
auth-client.ts
3
Update the route handler
Rename
/app/api/auth/[...nextauth] to /app/api/auth/[...all], then
update route.ts:- Auth.js
- Better Auth
app/api/auth/[...nextauth]/route.ts
4
5
6
Protect routes
Better Auth recommends checking the session on each page or route rather
than relying on middleware for full authorization.
- Server component
- Client component
app/dashboard/page.tsx