{
  "slug": "stitch-firebase-with-clerk-bootstrap",
  "title": "Stitch firebase with clerk session bootstrap",
  "metaDescription": "Stitch firebase with clerk session bootstrap. Clerk session and Firebase FCM registration merged at s. Merge Firebase and Clerk in one React Native.",
  "headline": "Mobile launch auth plus push config",
  "category": "aggregation",
  "categoryLabel": "Multi-API Aggregation",
  "urgency": 9,
  "clientPlatform": "React Native",
  "upstreamServices": [
    "Firebase",
    "Clerk"
  ],
  "searchIntentQuery": "stitch firebase with clerk session bootstrap",
  "directAnswerSummary": "Clerk session and Firebase FCM registration merged at startup. For \"stitch firebase with clerk session bootstrap\", store FIREBASE_ACCESS_TOKEN, CLERK_SECRET_KEY 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/stitch-firebase-with-clerk-bootstrap with an rc_live_ client token.",
  "problem": {
    "title": "Serial Firebase and Clerk calls slow React Native pages",
    "explanation": "Each extra Firebase and Clerk hop adds hundreds of milliseconds and another OAuth refresh path your UI must manage.",
    "risks": [
      "One slow upstream blocking an entire page",
      "Partial failures leaving UI in inconsistent states",
      "Duplicate auth refresh logic per service"
    ]
  },
  "solutionSteps": [
    {
      "stepNumber": 1,
      "title": "Add vault secrets for this pipeline",
      "description": "Add FIREBASE_ACCESS_TOKEN, CLERK_SECRET_KEY to RealComposer Secret Vault. Values decrypt only inside the Cloudflare Worker that calls the upstream."
    },
    {
      "stepNumber": 2,
      "title": "Set headers, mapping, and cache TTL",
      "description": "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)."
    },
    {
      "stepNumber": 3,
      "title": "Call from React Native",
      "description": "Call https://realcomposer.com/v1/workspace/stitch-firebase-with-clerk-bootstrap with a restricted rc_live_ client token. React Native never sends upstream secrets.",
      "codeSnippet": "const res = await fetch('https://realcomposer.com/v1/workspace/stitch-firebase-with-clerk-bootstrap', {\n  headers: { Authorization: 'Bearer rc_live_your_token' }\n});"
    }
  ],
  "pipelineConfig": {
    "name": "Stitch firebase with clerk session bootstrap",
    "method": "GET",
    "cacheTtlSeconds": 0,
    "authMode": "client_token",
    "steps": [
      {
        "stepKey": "firebase",
        "upstreamUrlTemplate": "https://firestore.googleapis.com/v1/projects/{{query.projectId}}/databases/(default)/documents/{{query.collection}}/{{query.docId}}",
        "httpMethod": "GET",
        "headersTemplate": {
          "Authorization": "Bearer {{secrets.FIREBASE_ACCESS_TOKEN}}"
        },
        "timeoutMs": 3000
      },
      {
        "stepKey": "clerk",
        "upstreamUrlTemplate": "https://api.clerk.com/v1/users/{{query.userId}}",
        "httpMethod": "GET",
        "headersTemplate": {
          "Authorization": "Bearer {{secrets.CLERK_SECRET_KEY}}"
        },
        "timeoutMs": 3000
      }
    ],
    "outputMapping": {
      "version": 1,
      "fields": [
        {
          "targetPath": "firebase.docName",
          "sourcePath": "name",
          "type": "string",
          "sourceStep": "firebase"
        },
        {
          "targetPath": "firebase.fields",
          "sourcePath": "fields",
          "type": "object",
          "sourceStep": "firebase"
        },
        {
          "targetPath": "clerk.userId",
          "sourcePath": "id",
          "type": "string",
          "sourceStep": "clerk"
        },
        {
          "targetPath": "clerk.email",
          "sourcePath": "email_addresses.0.email_address",
          "type": "string",
          "sourceStep": "clerk"
        }
      ]
    }
  },
  "sampleBloatedInput": {
    "requestId": "req_stitch-f",
    "upstreamLatencyMs": 142,
    "audit": {
      "region": "edge",
      "trace": "stitch-firebase-with-clerk-bootstrap"
    },
    "payload": {
      "id": "sample_id",
      "status": "active",
      "nested": {
        "tags": [
          "demo"
        ],
        "internal": true
      },
      "unused_blob": {
        "foo": "bar",
        "bar": "baz"
      }
    }
  },
  "sampleSlimmedOutput": {
    "firebase_docName": "sample",
    "firebase_fields": "sample",
    "clerk_userId": "sample",
    "clerk_email": "sample"
  },
  "curlSnippet": "curl -X GET \"https://realcomposer.com/v1/workspace/stitch-firebase-with-clerk-bootstrap\" \\\n  -H \"Authorization: Bearer rc_live_client_token\"",
  "faqs": [
    {
      "question": "What should React Native store instead of Firebase secrets?",
      "answer": "Yes for stitch-firebase-with-clerk-bootstrap. 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}}."
    },
    {
      "question": "Will Anthropic or Linear prompt bodies be rewritten?",
      "answer": "stitch-firebase-with-clerk-bootstrap POST steps bypass caches.default even if cacheTtlSeconds is set in the dashboard."
    },
    {
      "question": "What happens if an upstream step times out?",
      "answer": "Rotate vault secrets for stitch-firebase-with-clerk-bootstrap anytime; clients keep the same rc_live_ token."
    }
  ],
  "relatedRecipeSlugs": [
    "merge-clerk-and-posthog-feature-flags",
    "combine-firebase-auth-with-supabase-profile"
  ],
  "updatedAt": "2026-11-20",
  "links": {
    "page": "https://realcomposer.com/recipes/stitch-firebase-with-clerk-bootstrap",
    "markdown": "https://realcomposer.com/recipes/stitch-firebase-with-clerk-bootstrap.md",
    "json": "https://realcomposer.com/recipes/stitch-firebase-with-clerk-bootstrap.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=stitch-firebase-with-clerk-bootstrap&via=agent"
  }
}