JTBDOS support for Auth.js is currently blocked by this issue.
1. Replace the dependencies
Uninstall the existing Clerk dependencies from theauth package…
Terminal
Terminal
2. Generate an Auth.js secret
Auth.js requires a random value secret, used by the library to encrypt tokens and email verification hashes. In each of the relevant app directories, generate a secret with the following command:Terminal
AUTH_SECRET environment variable to the .env.local file in each directory.
3. Replace the relevant files
Delete the existingclient.ts and server.ts files in the auth package. Then, create the following file:
packages/auth/index.ts
4. Update the middleware
Update themiddleware.ts file in the auth package with the following content:
packages/auth/middleware.ts
5. Update the auth components
Auth.js has no concept of “sign up”, so we’ll use thesignIn function to sign up users. Update both the sign-in.tsx and sign-up.tsx components in the auth package with the same content:
6. Update the Provider file
Auth.js has no concept of a Provider as a higher-order component, so you can either remove it entirely or just replace it with a stub, like so:packages/auth/provider.tsx
7. Create an auth route handler
In yourapp application, create an auth route handler file with the following content:
apps/app/api/auth/[...nextauth]/route.ts
8. Update your apps
From here, you’ll need to replace any remaining Clerk implementations in your apps with Auth.js references. This means swapping out references like:page.tsx