Generate a JWT secret
Create a strong, random secret for signing tokens:JWT_SECRET (or AUTH_SECRET) in each project’s .env.
Token lifetimes
Recommended defaults:- Access token:
15 minutes - Refresh token:
7 days
Refresh token handling
Keep refresh tokens secure:- Store them in
httpOnlycookies or a secure key store - Rotate and invalidate them on logout and after password changes
- Revoke tokens server-side when a user logs out or a token is suspected to be leaked