Docs
Authentification

Authentification

How to config the authentification.

The auth part is similar at the authjs documentation. You can follow the official documentation here if you want.

After upgrade Auth.js to v5: NEXTAUTH_URL has been removed from .env file. Same thing in production. Auth.js v5 automatically detects the URL.

Auth.js v5 Environment Variables

Project uses Auth.js v5 with Prisma adapter. Set these variables in .env.local:

# Core (required)
AUTH_SECRET=your-secret-here
AUTH_GOOGLE_ID=your-google-client-id
AUTH_GOOGLE_SECRET=your-google-client-secret
 
# Email provider (Resend)
RESEND_API_KEY=re_your_resend_api_key
EMAIL_FROM=login@your-domain.com
 
# Optional providers
AUTH_TIKTOK_ID=
AUTH_TIKTOK_SECRET=
 
# Optional for legacy deploy contexts (v5 auto-detects)
NEXTAUTH_URL=https://your-app-url

The only strictly mandatory variable is AUTH_SECRET. It encrypts tokens and email verification hashes. Generate it via:

npx auth secret

Alternatively, you can use the openssl CLI, openssl rand -base64 33.

Or this link for generate a random secret key.

Then add it to your .env file:

.env.local
AUTH_SECRET = secret;

Google OAuth variables

In this section, you can update these variables:

.env.local
AUTH_GOOGLE_ID = your_secret_client_id.apps.googleusercontent.com;
AUTH_GOOGLE_SECRET = your_secret_client_secret;
 
## Providers used in this repo
 
- Google OAuth (always enabled)
- Resend Email (enabled on Node runtime only, not Edge)
- TikTok (optional, only if credentials provided)
 
The auth route is handled at `app/api/auth/[...nextauth]/route.ts` and configured via `auth.ts` and `auth.config.ts`. Custom pages: `/login` (sign-in) and `/auth/error`.
 
Cookies are configured with secure and domain options for production (`proviewr.com`). When self-hosting, adjust the domain or remove it if not needed.

Video explanation

Watch a youtube video from CodeWithAntonio on how to configure the environment variables for NextAuth with Google authentication.

  • GoogleAuth local config at 3:24:30
  • Update GoogleAuth after deployment at 7:52:31

Google config for this repo