Docs·UnderPeaks

Connecting Your Database · Firebase

Firebase

Create a Firebase project

  1. Go to console.firebase.google.com
  2. Click Add project and follow the setup steps
  3. Enable Firestore Database in your project

Get your credentials

Firebase needs two separate credentials:

  1. 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.
  2. 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_ACCOUNT is the entire downloaded JSON file, minified to a single line, wrapped in quotes. NEXT_PUBLIC_FIREBASE_CONFIG is 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.