If you see the error:
Error: Firebase environment variables are missing: NEXT_PUBLIC_FIREBASE_API_KEY,
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN, NEXT_PUBLIC_FIREBASE_PROJECT_ID,
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET, NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
NEXT_PUBLIC_FIREBASE_APP_ID. Please populate them in your environment.
Follow these steps:
- Go to Firebase Console
- Select or create your project
- Click the ⚙️ Settings icon → Project Settings
- Go to the Your apps section
- Find or create a Web app
- Copy the Firebase SDK configuration object
In the project root (E:\Development\Projects\Web\Project-Showcase\lern\),
create a .env.local file:
# Firebase Configuration
NEXT_PUBLIC_FIREBASE_API_KEY=AIzaSyD...
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your-project-id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your-project.appspot.com
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=123456789
NEXT_PUBLIC_FIREBASE_APP_ID=1:123456789:web:abc123...
# Groq API (Get from https://console.groq.com/keys)
GROQ_API_KEY=gsk_...
# Backend API
NEXT_PUBLIC_API_URL=http://localhost:3001/api
# Environment
NODE_ENV=developmentYour Firebase SDK config looks like:
{
apiKey: "AIzaSyD...",
authDomain: "your-project.firebaseapp.com",
projectId: "your-project-id",
storageBucket: "your-project.appspot.com",
messagingSenderId: "123456789",
appId: "1:123456789:web:abc123..."
}Map to environment variables: | Firebase Field | Environment Variable |
|---|---| | apiKey | NEXT_PUBLIC_FIREBASE_API_KEY | | authDomain |
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN | | projectId |
NEXT_PUBLIC_FIREBASE_PROJECT_ID | | storageBucket |
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET | | messagingSenderId |
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID | | appId |
NEXT_PUBLIC_FIREBASE_APP_ID |
- Go to Groq Console
- Create a new API key
- Copy and paste into
.env.localasGROQ_API_KEY
# Kill existing process
# Then restart
pnpm devAfter setting up, you should see:
- ✅ App loads without Firebase errors
- ✅ Can sign up/login with email/password
- ✅ Chat works with Groq AI
- ✅ Dark/light mode toggle works
This file is in .gitignore to prevent exposing secrets.
NEXT_PUBLIC_*- Safe to expose (frontend)GROQ_API_KEY- Backend only, should NOT beNEXT_PUBLIC_
Local Development:
- Use
.env.localfile (as described above) - Never commit this file to git
Production (Vercel):
- Configure environment variables in Vercel dashboard
- Go to: Project Settings → Environment Variables
- Add all the same variables (Firebase + Groq API key)
- Set for Production, Preview, and Development environments as needed
CI/CD (GitHub Actions):
- See CI_CD_SETUP.md for GitHub secrets configuration
- CI workflow uses dummy values for build, actual deployment uses Vercel env vars
- Firebase project created
- Web app registered in Firebase
-
.env.localfile created - All 6 Firebase variables filled in
- Groq API key added
- Development server restarted
- App loads without errors
- Can sign up with email/password
- Chat responds with AI
- Vercel project created and linked
- Environment variables configured in Vercel dashboard
- All Firebase variables added to Vercel
- Groq API key added to Vercel
- GitHub secrets configured (for CI/CD)
-
VERCEL_TOKENadded to GitHub secrets -
VERCEL_ORG_IDadded to GitHub secrets -
VERCEL_PROJECT_IDadded to GitHub secrets (optional)
-
- CI/CD workflow runs successfully
- Production deployment works
📖 For detailed CI/CD setup, see CI_CD_SETUP.md
- Check
.env.localexists in project root - Verify all NEXTPUBLIC_FIREBASE* variables are set
- Restart development server
- Check for typos in variable names (must match exactly)
- Firebase config is null
- Check if all variables are correctly set
- Verify no trailing/leading spaces in values
- Verify
GROQ_API_KEYis set - Check Groq API key is valid
- Ensure
NEXT_PUBLIC_API_URLpoints to correct backend
- Verify Firebase Auth is enabled
- Check Email/Password provider is enabled in Firebase Console
- Verify Firebase config is correct
| Variable | Description | Where to Set |
|---|---|---|
NEXT_PUBLIC_FIREBASE_API_KEY |
Firebase API key | .env.local, Vercel, GitHub Secrets (optional) |
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN |
Firebase auth domain | .env.local, Vercel, GitHub Secrets (optional) |
NEXT_PUBLIC_FIREBASE_PROJECT_ID |
Firebase project ID | .env.local, Vercel, GitHub Secrets (optional) |
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET |
Firebase storage bucket | .env.local, Vercel, GitHub Secrets (optional) |
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID |
Firebase messaging sender ID | .env.local, Vercel, GitHub Secrets (optional) |
NEXT_PUBLIC_FIREBASE_APP_ID |
Firebase app ID | .env.local, Vercel, GitHub Secrets (optional) |
GROQ_API_KEY |
Groq AI API key | .env.local, Vercel |
NEXT_PUBLIC_API_URL |
Backend API URL | .env.local, Vercel |
| Secret | Description | Required |
|---|---|---|
VERCEL_TOKEN |
Vercel authentication token | ✅ Yes |
VERCEL_ORG_ID |
Vercel organization/team ID | ✅ Yes |
VERCEL_PROJECT_ID |
Vercel project ID |
Note: Environment variables for builds can be added as GitHub secrets, but production deployments should use Vercel's environment variables.
lern/
├── .env.local ← CREATE THIS (local only, not in git)
├── .gitignore ← Already ignores .env.local
├── .github/
│ └── workflows/
│ └── ci.yml ← CI/CD workflow
├── docs/
│ ├── SETUP_ENV.md ← This file
│ └── CI_CD_SETUP.md ← CI/CD setup guide
└── src/
├── lib/firebase/config.ts ← Reads env variables
└── ...
- Local Development: Follow the steps above to set up
.env.local - Production Deployment:
- Configure environment variables in Vercel dashboard
- See CI_CD_SETUP.md for GitHub Actions setup
- CI/CD: Set up GitHub secrets for automated deployments
Status: Follow this guide to get your app running! 🚀