Can you keep a secret?
Generate random 32-byte, base64 secrets for your Payload instance.
Development
Add the secret to your .env file:
PAYLOAD_SECRET="your_generated_secret_here"
For local development with Docker, add it to your docker-compose.yml environment variables:
environment:
PAYLOAD_SECRET: "your_generated_secret_here"
Production
Set the secret in your hosting platform:
Vercel
# Using Vercel CLI
vercel env add PAYLOAD_SECRET your_generated_secret_here
# Or add via Vercel dashboard:
# Project Settings > Environment Variables > Add New
Railway
# Add via Railway dashboard:
# Project Settings > Variables > New Variable
PAYLOAD_SECRET=your_generated_secret_here
Netlify
# Using Netlify CLI
netlify env:set PAYLOAD_SECRET your_generated_secret_here
# Or add via Netlify dashboard:
# Site settings > Environment variables > Add variable
Code
In your Payload config:
import { buildConfig } from 'payload/config';
export default buildConfig({
secret: process.env.PAYLOAD_SECRET,
// ... rest of your config
});
For TypeScript projects:
import { buildConfig } from 'payload/config';
import { Config } from 'payload/types';
const config: Config = buildConfig({
secret: process.env.PAYLOAD_SECRET,
// ... rest of your config
});
export default config;