.env.local file at the project root.
Create your .env.local file
.env.local
Supabase variables
Your Supabase project URL. Found in the Supabase dashboard under Settings → API → Project URL.Example:
https://abcdefghijklmnop.supabase.coThis is a public variable (prefixed NEXT_PUBLIC_) and is safe to expose in the browser.Your Supabase publishable key (the newer variable name introduced in recent Supabase SDK versions). Found in the Supabase dashboard under Settings → API → Project API Keys.The codebase checks for this variable first, falling back to
NEXT_PUBLIC_SUPABASE_ANON_KEY if not set. Use whichever key name your Supabase project provides.Your Supabase anonymous (public) key (the legacy variable name, still fully supported). Found in the Supabase dashboard under Settings → API → Project API Keys → anon public.This is a public variable. It is safe to expose in the browser — access is governed by Row Level Security policies. Use this if your project does not have
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY.You only need one of
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY or NEXT_PUBLIC_SUPABASE_ANON_KEY. The client checks NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY first, then falls back to NEXT_PUBLIC_SUPABASE_ANON_KEY.Cloudflare R2 variables
All R2 variables are server-only (noNEXT_PUBLIC_ prefix) and are never sent to the browser.
Your Cloudflare R2 bucket endpoint URL. Found in the Cloudflare dashboard under R2 → your bucket → Settings → S3 API.Format:
https://<ACCOUNT_ID>.r2.cloudflarestorage.comR2 access key ID. Generate in the Cloudflare dashboard under R2 → Manage R2 API Tokens → Create API Token.Select Object Read & Write permissions scoped to your bucket.
R2 secret access key. Generated alongside
R2_ACCESS_KEY_ID. Only shown once — store it securely.The name of your R2 bucket where uploaded files are stored.Example:
rajat-mahotsav-uploadsA path prefix prepended to all uploaded file keys. Used to organize uploads within the bucket.Example:
uploads/ or seva/Include the trailing slash.How variables are used
| Variable | Used in | Purpose |
|---|---|---|
NEXT_PUBLIC_SUPABASE_URL | Client & Server | Supabase project connection |
NEXT_PUBLIC_SUPABASE_ANON_KEY | Client & Server | Supabase authentication |
R2_ENDPOINT | API routes only | R2 S3-compatible endpoint |
R2_ACCESS_KEY_ID | API routes only | R2 authentication |
R2_SECRET_ACCESS_KEY | API routes only | R2 authentication |
R2_BUCKET_NAME | API routes only | Upload target bucket |
R2_BUCKET_PREFIX | API routes only | Upload key organization |
R2 variables are only accessed in Next.js API routes (
app/api/). They are never included in the client-side bundle.