Environment Setup
Learn how to configure environment variables and settings for development and production.
Environment Files
The project uses different environment files for different environments:
.env.local
Used for local development. Never commit this file.
# Supabase configuration
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
# Stripe configuration
STRIPE_SECRET_KEY=your_stripe_secret_key
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=your_stripe_publishable_key
STRIPE_WEBHOOK_SECRET=your_stripe_webhook_secret
# Email configuration
RESEND_API_KEY=your_resend_api_key
# Application configuration
NEXT_PUBLIC_SITE_URL=http://localhost:3000
NODE_ENV=development
.env.production
Used for production deployment. Configure these in your Vercel dashboard.
# Production environment variables are set in Vercel dashboard
NEXT_PUBLIC_SITE_URL=https://your-domain.com
NODE_ENV=production
# Other variables remain the same but with production values
Environment Variables Guide
Supabase Configuration
NEXT_PUBLIC_SUPABASE_URL
Your Supabase project URL
NEXT_PUBLIC_SUPABASE_ANON_KEY
Your Supabase anonymous key for public API access
Stripe Configuration
STRIPE_SECRET_KEY
Your Stripe secret key for server-side operations
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
Your Stripe publishable key for client-side operations
STRIPE_WEBHOOK_SECRET
Your Stripe webhook signing secret for verifying webhook events
Email Configuration
RESEND_API_KEY
Your Resend API key for sending transactional emails
Local Development Setup
Follow these steps to set up your local environment:
Create .env.local file
cp .env.example .env.local
Configure Supabase
- Create a new project in Supabase
- Copy project URL and anon key from project settings
- Update .env.local with these values
Set up Stripe
- Create a Stripe account
- Get API keys from Stripe dashboard
- Install Stripe CLI for webhook testing
- Update .env.local with Stripe keys
Configure Resend
- Create a Resend account
- Generate API key
- Update .env.local with Resend API key
Environment Type Safety
The project includes type safety for environment variables using the following setup:
// src/env.mjs
import { createEnv } from "@t3-oss/env-nextjs";
import { z } from "zod";
export const env = createEnv({
server: {
STRIPE_SECRET_KEY: z.string().min(1),
STRIPE_WEBHOOK_SECRET: z.string().min(1),
RESEND_API_KEY: z.string().min(1),
},
client: {
NEXT_PUBLIC_SITE_URL: z.string().url(),
NEXT_PUBLIC_SUPABASE_URL: z.string().url(),
NEXT_PUBLIC_SUPABASE_ANON_KEY: z.string().min(1),
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: z.string().min(1),
},
runtimeEnv: process.env,
});