Environment Variables
Fast Forward Dev requires several environment variables to connect to external services. This guide explains each variable and where to get the values.
Client Environment Variables
Create a .env.local file in the client root directory with the following variables:
NextAuth Configuration
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your-secret-key-here- NEXTAUTH_URL: The base URL of your application
- Development:
http://localhost:3000 - Production: Your production domain (e.g.,
https://yourdomain.com)
- Development:
- NEXTAUTH_SECRET: A random string for encrypting tokens
- Generate one: Run
openssl rand -base64 32in your terminal
- Generate one: Run
Stripe Keys
# Test keys (for development)
PUBLIC_TEST_STRIPE_PUBLISHABLE_KEY=pk_test_...
# Production keys
PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_live_...Where to get them:
- Go to Stripe Dashboard
- Click “Developers” → “API keys”
- Copy the “Publishable key” (starts with
pk_test_orpk_live_)
The app automatically uses test keys in development and production keys in production based on NODE_ENV.
Google OAuth (Optional)
GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-client-secretWhere to get them:
- Go to Google Cloud Console
- Create a new project or select existing
- Go to “APIs & Services” → “Credentials”
- Click “Create Credentials” → “OAuth 2.0 Client ID”
- Set authorized redirect URIs:
- Development:
http://localhost:3000/api/auth/callback/google - Production:
https://yourdomain.com/api/auth/callback/google
- Development:
Server Environment Variables
Create a .env file in the server root directory with the following variables:
Database Configuration
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/databaseWhere to get it:
- Go to MongoDB Atlas
- Create a free cluster
- Click “Connect” → “Connect your application”
- Copy the connection string
- Replace
<password>with your database password - Replace
<database>with your database name
JWT Secret
JWT_SECRET=your-jwt-secret-here- Generate a secure random string:
openssl rand -base64 32 - This is used to sign authentication tokens
Never share your JWT_SECRET. It should be different from your NEXTAUTH_SECRET.
Stripe Keys
# Test keys (for development)
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
# Production keys
# STRIPE_SECRET_KEY=sk_live_...
# STRIPE_WEBHOOK_SECRET=whsec_...Where to get them:
Secret Key:
- Go to Stripe Dashboard
- Click “Developers” → “API keys”
- Copy the “Secret key” (starts with
sk_test_orsk_live_)
Webhook Secret:
- Go to “Developers” → “Webhooks”
- Click “Add endpoint”
- Set the endpoint URL:
- Development: Use Stripe CLI for local testing
- Production:
https://yourdomain.com/api/stripe/webhook
- Select events to listen for:
checkout.session.completedcustomer.subscription.updatedcustomer.subscription.deleted
- Copy the “Signing secret” (starts with
whsec_)
Email Configuration (Resend)
RESEND_API_KEY=re_...Where to get it:
- Go to Resend
- Sign up for an account (free tier available)
- Go to “API Keys”
- Create a new API key
- Copy the key (starts with
re_)
Google OAuth Verification
GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.comThis should be the same client ID you created for the client.
Server Configuration
NODE_ENV=development
PORT=5001
CLIENT_URL=http://localhost:3000- NODE_ENV:
developmentorproduction - PORT: Port for the Express server (default:
5001) - CLIENT_URL: URL of your Next.js client
- Development:
http://localhost:3000 - Production:
https://yourdomain.com
- Development:
Complete Example Files
Client .env.local Example
# NextAuth
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your_nextauth_secret_key
# Stripe (Test Keys)
PUBLIC_TEST_STRIPE_PUBLISHABLE_KEY=pk_test_...
PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_live_...
# Google OAuth (Optional)
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secretServer .env Example
# Database
MONGODB_URI=mongodb+srv://user:password@cluster.mongodb.net/dbname
# JWT
JWT_SECRET=your_jwt_secret_key
# Stripe
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
# Email
RESEND_API_KEY=re_...
# Google OAuth
GOOGLE_CLIENT_ID=your_google_client_id
# Server
NODE_ENV=development
PORT=5001
CLIENT_URL=http://localhost:3000Security Best Practices
Important Security Tips:
- Never commit
.envor.env.localfiles to Git (they’re in.gitignore) - Use different secrets for development and production
- Rotate secrets regularly
- Never share secrets in screenshots or documentation
- Use environment variables in your deployment platform (Vercel, Heroku, etc.)
Troubleshooting
Missing Environment Variables
If you see errors about missing environment variables:
- Check that the variable is defined in the correct
.envfile - Restart your development server after changing
.envfiles - Make sure there are no typos in variable names
- Ensure there are no spaces around the
=sign
Variables Not Loading
- Client variables must start with
PUBLIC_to be accessible (except NextAuth variables) - Server variables are loaded automatically by
dotenv - Make sure
.envfiles are in the root directory, not in subdirectories
Next Steps
Once you have all your environment variables set up, continue with:
- Running Locally - Start your development servers
- Stripe Payments - Set up payments
- Deployment - Deploy to production