Environment Setup โ Quick Start Guide โ
Time to complete: ~20 minutes
Follow these steps in order to get your local development environment running and deployments configured.
Environment Detection Pattern โ
IMPORTANT: When adding dev-only features (debug panels, simulate buttons, etc.), use hostname-based detection:
const hostname = typeof window !== 'undefined' ? window.location.hostname : ''
const isProductionEnv = import.meta.env.VITE_APP_ENV === 'production' || hostname === 'ourlantern.app'
const isDev = !isProductionEnvWhy hostname check?
import.meta.env.DEVonly works on localhost (Vite dev server)- Deployed dev sites (dev.ourlantern.app) need hostname detection
- Production site (ourlantern.app) should hide all dev features
Examples in codebase:
src/screens/dashboard/Dashboard.jsx- "Simulate Wave" buttonsrc/screens/profile/ProfileSettings.jsx- Location spoof panelsrc/firebase.js- Firebase environment logging
Step-by-Step Checklist โ
โ Step 1: Install Dependencies (2 min) โ
cd lantern_app
npm installVerify: Run npm --version โ should show v8 or higher.
โ Step 2: Create Firebase DEV Project (5 min) โ
- Go to https://console.firebase.google.com
- Click "Add project"
- Name:
lantern-app-dev - Disable Google Analytics (or enable if you want)
- Click "Create project"
Wait for project to be created (~1 minute).
โ Step 3: Enable Firebase Services in DEV (3 min) โ
In your lantern-app-dev project:
Authentication:
- Click "Authentication" in left sidebar
- Click "Get started"
- Click "Email/Password"
- Enable the toggle
- Click "Save"
Firestore Database:
- Click "Firestore Database"
- Click "Create database"
- Choose "Start in test mode"
- Select region (e.g.,
us-central1) - Click "Enable"
Storage:
- Click "Storage"
- Click "Get started"
- Start in test mode
- Click "Next" โ "Done"
โ Step 4: Get Firebase DEV Config (2 min) โ
- In Firebase Console, click โ๏ธ (gear icon) โ "Project settings"
- Scroll down to "Your apps"
- Click web icon
</>(if no apps exist) - App nickname: "Lantern Dev"
- Click "Register app"
- COPY the config object that looks like:
const firebaseConfig = {
apiKey: "AIzaSy...",
authDomain: "lantern-app-dev.firebaseapp.com",
projectId: "lantern-app-dev",
storageBucket: "lantern-app-dev.appspot.com",
messagingSenderId: "123456789",
appId: "1:123456789:web:abc..."
};โ ๏ธ Keep this open โ you'll need it in the next step!
โ Step 5: Set Up Local Environment File (2 min) โ
In your terminal:
# Copy the example file
cp .env.local.example .env.localOpen .env.local in your editor and paste your Firebase config values:
VITE_FIREBASE_API_KEY=AIzaSy... # Copy from firebaseConfig.apiKey
VITE_FIREBASE_AUTH_DOMAIN=lantern-app-dev.firebaseapp.com
VITE_FIREBASE_PROJECT_ID=lantern-app-dev
VITE_FIREBASE_STORAGE_BUCKET=lantern-app-dev.appspot.com
VITE_FIREBASE_MESSAGING_SENDER_ID=123456789
VITE_FIREBASE_APP_ID=1:123456789:web:abc...
VITE_APP_ENV=local
# OPTIONAL: Development Location Spoofing
# For testing venue-based features without leaving home
# Format: "latitude,longitude" (no spaces)
# Example: VITE_DEV_TEST_LOCATION="40.7128,-74.0060"
VITE_DEV_TEST_LOCATION=""Save the file.
๐งช Optional: Location Spoofing for Development โ
Lantern includes location-based features (check-ins, nearby users, venue offers). To test these features without physically visiting venues, you can spoof your location in development.
Two ways to set your test location:
Option 1: Environment Variable (Auto-loads on startup) โ
In .env.local, set your test coordinates:
VITE_DEV_TEST_LOCATION="40.7128,-74.0060"Get coordinates from Google Maps:
- Right-click any location on Google Maps
- Click the coordinates that appear (e.g., "40.7128, -74.0060")
- They'll copy to your clipboard
- Paste into
.env.local
Restart dev server for changes to take effect.
Option 2: Debug Panel (Change on-the-fly) โ
When running in development mode (npm run dev):
- Go to Profile Settings (
#/profile) - Click the "Privacy" tab
- Scroll down to see the purple "๐ง Dev: Location Spoofing" panel
- Enter latitude and longitude
- Click "Set Location"
The spoofed location persists in localStorage until you clear it.
Tip: Spoof your location to:
- Your home address (for testing from home)
- A local bar/venue (test venue check-ins)
- Different cities (test geographic features)
โ ๏ธ Location spoofing is only available in development mode โ production builds automatically use real geolocation.
โ Step 6: Test Local Development (1 min) โ
npm run devOpen browser to http://localhost:5173
Verify:
- App loads without errors
- Open browser console (F12)
- Look for:
๐ฅ Firebase initialized (local environment) - Check it says
Project: lantern-app-dev
โ Success! Your local environment is working!
Press Ctrl+C to stop the dev server.
โ Step 7: Create Firebase PRODUCTION Project (5 min) โ
Repeat Steps 2-4 but name the project lantern-app-prod:
- Firebase Console โ Add project
- Name:
lantern-app-prod - Enable Authentication, Firestore, Storage (same as dev)
- Get the config (โ๏ธ โ Project settings โ Add web app โ "Lantern Prod")
โ ๏ธ Save both configs (dev AND prod) โ you'll need them for Cloudflare.
โ Step 8: Set Up Cloudflare Pages (10 min) โ
Prerequisites: Have your GitHub repo cattreedev/lantern_app ready.
8.1: Create Cloudflare Pages Project โ
- Go to https://dash.cloudflare.com
- Click "Pages" in left sidebar
- Click "Create a project"
- Click "Connect to Git"
- Authorize GitHub (if needed)
- Select repository:
cattreedev/lantern_app - Click "Begin setup"
8.2: Configure Build Settings โ
- Project name:
lantern-app - Production branch:
main - Build command:
npm run build - Build output directory:
dist - Root directory: (leave empty or
/)
Click "Save and Deploy" (it will fail first time โ that's OK!)
8.3: Set Environment Variables โ
- Go to your Cloudflare Pages project
- Click "Settings" โ "Environment variables"
For Production (main branch):
Click "Add variable" for each of these (using your lantern-app-prod config):
| Variable Name | Value (from lantern-app-prod) |
|---|---|
VITE_FIREBASE_API_KEY | AIzaSy... (prod) |
VITE_FIREBASE_AUTH_DOMAIN | lantern-app-prod.firebaseapp.com |
VITE_FIREBASE_PROJECT_ID | lantern-app-prod |
VITE_FIREBASE_STORAGE_BUCKET | lantern-app-prod.appspot.com |
VITE_FIREBASE_MESSAGING_SENDER_ID | 123... (prod) |
VITE_FIREBASE_APP_ID | 1:123... (prod) |
VITE_APP_ENV | production |
NODE_VERSION | 20 |
For Preview (all other branches):
Repeat above, but use values from lantern-app-dev config:
| Variable Name | Value (from lantern-app-dev) |
|---|---|
VITE_FIREBASE_API_KEY | AIzaSy... (dev) |
VITE_FIREBASE_AUTH_DOMAIN | lantern-app-dev.firebaseapp.com |
VITE_FIREBASE_PROJECT_ID | lantern-app-dev |
VITE_FIREBASE_STORAGE_BUCKET | lantern-app-dev.appspot.com |
VITE_FIREBASE_MESSAGING_SENDER_ID | 123... (dev) |
VITE_FIREBASE_APP_ID | 1:123... (dev) |
VITE_APP_ENV | development |
NODE_VERSION | 20 |
Click "Save"
โ Step 9: Trigger First Deployment โ
In your terminal:
# Make a small change to trigger deployment
echo "# Deployment test" >> README.md
# Commit and push
git add .
git commit -m "Configure deployment environment"
git push origin mainWait ~2 minutes for build.
Go to Cloudflare Pages โ "Deployments" to watch progress.
โ Success! When build completes, visit your production URL!
โ Step 10: Create Dev Branch โ
# Create dev branch from main
git checkout -b dev
git push origin devIn Cloudflare Pages:
- Go to Settings โ Builds & deployments
- Verify "Preview deployments" is enabled for all branches
Now when you push to dev, it auto-deploys to a preview URL!
๐ You're Done! โ
What You Just Set Up โ
- โ Local development environment
- โ Two Firebase projects (dev + prod)
- โ Cloudflare Pages automatic deployments
- โ Environment-specific configurations
- โ
Git branch strategy (
mainfor prod,devfor staging)
Your Workflow Now โ
Daily development:
# 1. Work locally
npm run dev
# 2. Commit changes
git add .
git commit -m "Add feature"
# 3. Push to dev branch
git push origin dev
# โ Auto-deploys to preview URL for testing
# 4. When ready, merge to main
git checkout main
git merge dev
git push origin main
# โ Auto-deploys to production!Common Issues & Fixes โ
Build fails on Cloudflare:
- Check you set
NODE_VERSION=20 - Verify all
VITE_*variables are set - Check build logs in Cloudflare dashboard
"Firebase not initialized" error:
- Verify environment variables in Cloudflare
- Ensure variable names start with
VITE_ - Check spelling/typos in variable names
Wrong Firebase project connecting:
- Check which branch you're on
- Verify Cloudflare environment variables for Production vs Preview
- Look in browser console for "Firebase initialized" message
Next Steps โ
Now that environment is set up:
- ๐ Read DEPLOYMENT.md for full deployment guide
- ๐ Add Firebase Security Rules (don't leave in test mode!)
- ๐ Set up Cloudflare Access for password protection
- ๐ Start building features!
Need help? Check docs/engineering/ or open an issue!