Back to migration guides
api • 1.0.0 → 2.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
automatedRemove next-auth, add jose and custom auth packages
npm uninstall next-auth && npm install jose2. Update session imports
manualReplace all next-auth/react imports with @/lib/auth/session
3. Update API route handlers
manualReplace getServerSession() with getSession() in all API routes
4. Update middleware
manualReplace NextAuth middleware with custom JWT verification middleware
5. Run migration script
automatedExecute database migration to add JWT-specific columns
npx prisma migrate dev