How to reduce firebase firestore json payload size
Flatten Firestore REST documents for lists
Strips document names revision metadata and map noise at edge. For "how to reduce firebase firestore json payload size", 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 Flutter / React Native / Swift hit only https://realcomposer.com/v1/workspace/reduce-firebase-firestore-json-size with an rc_live_ client token.
Firebase JSON bloat on Flutter / React Native / Swift
Oversized Firebase payloads inflate parse time and mobile data charges for Flutter / React Native / Swift users.
- Main-thread JSON parse stalls on low-end phones
- Accidentally exposing PII fields to the client
- Downstream components re-render on unused keys
How RealComposer Solves This at the Edge
Add vault secrets for this pipeline
Add FIREBASE_ACCESS_TOKEN to RealComposer Secret Vault. Values decrypt only inside the Cloudflare Worker that calls the upstream.
Set headers, mapping, and cache TTL
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 Flutter / React Native / Swift
Call https://realcomposer.com/v1/workspace/reduce-firebase-firestore-json-size with a restricted rc_live_ client token. Flutter / React Native / Swift never sends upstream secrets.
const res = await fetch('https://realcomposer.com/v1/workspace/reduce-firebase-firestore-json-size', {
headers: { Authorization: 'Bearer rc_live_your_token' }
});
{
"requestId": "req_reduce-f",
"upstreamLatencyMs": 142,
"audit": {
"region": "edge",
"trace": "reduce-firebase-firestore-json-size"
},
"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
- 254 B to 38 B (-85%)
curl -X GET "https://realcomposer.com/v1/workspace/reduce-firebase-firestore-json-size" \ -H "Authorization: Bearer rc_live_client_token"
Developer Questions & Troubleshooting
Can Flutter / React Native / Swift call Firebase without holding the production key?
Point Flutter / React Native / Swift at /recipes/reduce-firebase-firestore-json-size edge URL. RealComposer answers OPTIONS with Access-Control headers for allowed origins.
Does POST traffic get cached?
reduce-firebase-firestore-json-size keeps cache TTL at 0 because it uses POST upstream calls or per-user responses. Add ids to query strings before enabling GET cache.
What happens if an upstream step times out?
Rotate vault secrets for reduce-firebase-firestore-json-size anytime; clients keep the same rc_live_ token.
Sources & Definitions Used in This Answer
Deploy this Flutter / React Native / Swift + Firebase Recipe
Clone this pre-configured pipeline into your RealComposer workspace in one click. We pre-populate upstream URLs, headers, and mapping rules.