Hide firebase api key in react native mobile app
Mobile-safe Firebase identity and Firestore reads
Client uses anon rules; privileged reads run through edge proxy with Firebase tokens injected. For "hide firebase api key in react native mobile app", store FIREBASE_ACCESS_TOKEN in Secret Vault, call https://firestore.googleapis.com/v1/projects/{{query.projectId}}/databases/(default)/documents/{{query.collection}}/{{query.docId}} from a Worker, and let React Native hit only https://realcomposer.com/v1/workspace/hide-firebase-api-key-react-native with an rc_live_ client token.
Why React Native leaks Firebase credentials
Attackers routinely extract Firebase secrets from React Native builds. Direct browser calls also expose internal error payloads with hostnames.
- Production Firebase keys copied from React Native bundles
- Compliance violations after credential leaks
- Attackers replaying vault-grade scopes from a laptop
How RealComposer Solves This at the Edge
Store upstream credentials in Secret Vault
Create FIREBASE_ACCESS_TOKEN vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders.
Configure upstream steps and output mapping
Use GET against https://firestore.googleapis.com/v1/projects/{{query.projectId}}/databases/(default)/documents/{{query.collection}}/{{query.docId}}. Allowed origins on the client token should match leave cache ttl at 0 when each response is user-specific (include userid or record id in query params before enabling cache).
Call from React Native
Authorize with Bearer rc_live_ and fetch the mapped JSON contract your UI already expects.
const res = await fetch('https://realcomposer.com/v1/workspace/hide-firebase-api-key-react-native', {
headers: { Authorization: 'Bearer rc_live_your_token' }
});
{
"requestId": "req_hide-fir",
"upstreamLatencyMs": 142,
"audit": {
"region": "edge",
"trace": "hide-firebase-api-key-react-native"
},
"payload": {
"id": "sample_id",
"status": "active",
"nested": {
"tags": [
"demo"
],
"internal": true
},
"unused_blob": {
"foo": "bar",
"bar": "baz"
}
}
}
{
"docName": "sample",
"fields": "sample"
}
Recipe Specs
- HTTP method
- GET
- Upstream calls
- 1
- Edge cache TTL
- No caching
- Client auth
- Restricted client token
- Mapped output fields
- 2
- Payload
- 253 B to 38 B (-85%)
curl -X GET "https://realcomposer.com/v1/workspace/hide-firebase-api-key-react-native" \ -H "Authorization: Bearer rc_live_client_token"
Developer Questions & Troubleshooting
What should React Native store instead of Firebase secrets?
Yes for hide-firebase-api-key-react-native. Ship only an rc_live_ client token in React Native; RealComposer injects FIREBASE_ACCESS_TOKEN on https://firestore.googleapis.com/v1/projects/{{query.projectId}}/databases/(default)/documents/{{query.collection}}/{{query.docId}}.
Will Anthropic or Linear prompt bodies be rewritten?
Cache key for hide-firebase-api-key-react-native: internal edge-cache path plus sorted query. Identical params hit; vary userId per user.
Can I restrict which domains call this pipeline?
Upstream steps in hide-firebase-api-key-react-native honor timeoutMs and optional fallback JSON without leaking secrets.
Sources & Definitions Used in This Answer
Deploy this React Native + Firebase Recipe
Clone this pre-configured pipeline into your RealComposer workspace in one click. We pre-populate upstream URLs, headers, and mapping rules.