Connecting Your Database · Firebase
Firebase
Create a Firebase project
- Go to console.firebase.google.com
- Click Add project and follow the setup steps
- Enable Firestore Database in your project
Get your credentials
Firebase needs two separate credentials:
- Service account — in the Firebase console, go to Project Settings → Service accounts, click Generate new private key, and download the JSON file. This is server-only and must be kept secret.
- Web config — in Project Settings → General, under "Your apps," copy the web SDK config object (
apiKey,projectId, etc.). This is safe to expose to the browser.
Set environment variables
NEXT_PUBLIC_DB_TYPE=firebase
NEXT_DB_FIREBASE_SERVICE_ACCOUNT={"type":"service_account","project_id":"...", ...}
NEXT_PUBLIC_FIREBASE_CONFIG={"apiKey":"...","projectId":"...", ...}
NEXT_PUBLIC_FIREBASE_STORAGE_URL=your-project.appspot.com
NEXT_DB_FIREBASE_SERVICE_ACCOUNTis the entire downloaded JSON file, minified to a single line, wrapped in quotes.NEXT_PUBLIC_FIREBASE_CONFIGis the web SDK config object, also minified to a single line JSON string.
Notes
- Underpeaks uses the Firebase Admin SDK — not the client SDK.
- Firestore free tier (Spark plan) has limits of 50k reads and 20k writes per day.
- Firebase does not support SQL-style joins — relational queries are handled at the application layer.