Back to migration guides

api1.0.02.0.0

Migrate Authentication from NextAuth to Custom JWT

Complete guide for migrating from NextAuth session-based auth to custom JWT authentication with workspace support.

Upgrade steps

1. Update dependencies

automated

Remove next-auth, add jose and custom auth packages

npm uninstall next-auth && npm install jose

2. Update session imports

manual

Replace all next-auth/react imports with @/lib/auth/session

3. Update API route handlers

manual

Replace getServerSession() with getSession() in all API routes

4. Update middleware

manual

Replace NextAuth middleware with custom JWT verification middleware

5. Run migration script

automated

Execute database migration to add JWT-specific columns

npx prisma migrate dev