Deploy Firebase Functions for a React Native App
Some Instamobile apps include Firebase Functions for secure backend work such as feed updates, chat notifications, order dispatching, media processing, payments, AI requests, user moderation, and third-party API calls.
Quick Answer
Deploy Firebase Functions only if your app package includes a firebase/ or
Functions folder. Current Firebase-backed app packages use TypeScript, Firebase
Functions Gen2, Node 22, and Secret Manager-backed secrets. Install the
Functions dependencies, log in with the Firebase CLI, select your Firebase
project, configure required secrets, deploy the functions, then watch Firebase
logs while testing the app.
When This Page Applies
Use this guide if your app package includes files like:
firebase/
functions/
firebase.json
firestore.rules
storage.rules
firestore.indexes.json
Skip this page if your app does not include Firebase Functions and does not call backend endpoints.
1. Review the Included Firebase Folder
From the app root, inspect the Firebase backend:
ls firebase
ls firebase/functions
cat firebase/functions/package.json
Use the Node runtime and package manager implied by the included
firebase/functions/package.json and lockfile. Current app packages use Node 22
for Firebase Functions. Do not copy an old Functions project from another app
unless you also review dependencies, environment variables, and Firestore schema
differences.
2. Install Firebase CLI and Log In
Install the Firebase CLI using the current setup method recommended by Firebase or your project tooling, then authenticate:
firebase login
From the app's firebase/ folder, select your Firebase project:
cd firebase
firebase use --add
This writes or updates .firebaserc so deploy commands target your project.
3. Install Function Dependencies
Install dependencies in the Functions folder:
cd firebase/functions
corepack yarn install --immutable
If your older app package uses a different package manager, follow the included README and lockfile for that package.
Run the available checks before deploying:
corepack yarn typecheck
corepack yarn build
Return to the Firebase folder before deploying:
cd ..
4. Configure Required Secrets
Backend secrets must not be placed in the React Native app.
Depending on the app, Functions may need:
- Stripe secret key;
- Stripe webhook secret;
- OpenAI API key;
- Twilio credentials;
- Google Maps server key;
- SMTP or transactional email key;
- custom API tokens.
Use Firebase Functions secrets for private values. Example:
firebase functions:secrets:set STRIPE_SECRET_KEY
firebase functions:secrets:set OPENAI_API_KEY
Check the app-specific docs and firebase/functions source before deploy.
Avoid legacy runtime configuration for new projects. Do not put private keys in
the React Native app, and do not rely on functions.config() for current
Functions code unless your older package explicitly documents that requirement.
5. Deploy Rules and Indexes First
If included, deploy Firestore and Storage configuration before Functions:
firebase deploy --only firestore:rules
firebase deploy --only firestore:indexes
firebase deploy --only storage
This reduces runtime errors caused by missing permissions or missing indexes.
6. Deploy Functions
From the firebase/ folder:
firebase deploy --only functions
If the app uses specific function regions, keep the deployed region aligned with the URL or callable function name expected by the mobile app.
7. Watch Logs While Testing
Use Firebase Console or CLI logs while you exercise the app:
firebase functions:log
Test the flows that trigger backend code:
- sign up and profile update;
- create post or upload media;
- send chat message;
- place order or booking;
- start payment;
- call AI endpoint;
- report or block a user.
If App Check is enforced for Functions, Firestore, or Storage, confirm your iOS and Android builds send valid App Check tokens. For simulator and emulator testing, register debug tokens in Firebase Console before enabling enforcement.
Billing and Production Notes
Firebase Functions and backend-heavy workflows often require billing readiness. Review plan requirements before production:
- Firebase Costs and Blaze Plan
- Firebase Secrets and Environment Variables
- Firebase Production Checklist
Troubleshooting
| Problem | Fix |
|---|---|
firebase: command not found | Install the Firebase CLI and restart the terminal. |
| Deploy targets the wrong project | Run firebase use --add from the app's firebase/ folder. |
| Function deploy fails on runtime/dependencies | Check firebase/functions/package.json, lockfile, and Node runtime requirements. |
| App shows generic internal error | Open Functions logs and check missing secrets, permissions, billing, or region mismatch. |
| App Check blocks requests | Register the development debug token or disable enforcement until the app sends valid tokens. |
| Missing index error | Deploy firestore.indexes.json or create the index from the Firebase error link. |
| Upload or payment fails | Check Functions deploy, Storage rules, Firestore rules, secrets, and Firebase billing. |