{
  "slug": "stitch-firebase-with-algolia-search",
  "title": "Stitch firebase firestore with algolia search index",
  "metaTitle": "Stitch firebase firestore with - RealComposer",
  "metaDescription": "Stitch firebase firestore with algolia search index. Firestore document fetch and Algolia query in one searc. Merge Firebase and Algolia in one React.",
  "headline": "Firestore sync search bootstrap",
  "category": "aggregation",
  "categoryLabel": "Multi-API Aggregation",
  "urgency": 8,
  "clientPlatform": "React",
  "upstreamServices": [
    "Firebase",
    "Algolia"
  ],
  "searchIntentQuery": "stitch firebase firestore with algolia search index",
  "directAnswerSummary": "Firestore document fetch and Algolia query in one search-as-you-type call. For \"stitch firebase firestore with algolia search index\", store FIREBASE_ACCESS_TOKEN, ALGOLIA_API_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 hit only https://realcomposer.com/v1/workspace/stitch-firebase-with-algolia-search with an rc_live_ client token. POST upstream calls are not stored in caches.default; clients must send JSON bodies and headers forward unchanged.",
  "problem": {
    "title": "Serial Firebase and Algolia calls slow React pages",
    "explanation": "Each extra Firebase and Algolia 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": "Bind vault keys to the Worker",
      "description": "Create FIREBASE_ACCESS_TOKEN, ALGOLIA_API_KEY vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders."
    },
    {
      "stepNumber": 2,
      "title": "Configure upstream steps and output mapping",
      "description": "Configure headersTemplate to inject vault secrets, target https://firestore.googleapis.com/v1/projects/{{query.projectId}}/databases/(default)/documents/{{query.collection}}/{{query.docId}}, and Add output mapping fields that mirror the JSON contract your screen already expects."
    },
    {
      "stepNumber": 3,
      "title": "Call from React",
      "description": "Authorize with Bearer rc_live_ and fetch the mapped JSON contract your UI already expects.",
      "codeSnippet": "const res = await fetch('https://realcomposer.com/v1/workspace/stitch-firebase-with-algolia-search', {\n  headers: { Authorization: 'Bearer rc_live_your_token' }\n});\nconst data = await res.json();"
    }
  ],
  "pipelineConfig": {
    "name": "Stitch firebase firestore with algolia search index",
    "method": "POST",
    "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": "algolia",
        "upstreamUrlTemplate": "https://{{secrets.ALGOLIA_APP_ID}}-dsn.algolia.net/1/indexes/{{query.index}}/query",
        "httpMethod": "POST",
        "headersTemplate": {
          "X-Algolia-API-Key": "{{secrets.ALGOLIA_API_KEY}}",
          "X-Algolia-Application-Id": "{{secrets.ALGOLIA_APP_ID}}",
          "Content-Type": "application/json"
        },
        "timeoutMs": 10000
      }
    ],
    "outputMapping": {
      "version": 1,
      "fields": [
        {
          "targetPath": "firebase.docName",
          "sourcePath": "name",
          "type": "string",
          "sourceStep": "firebase"
        },
        {
          "targetPath": "firebase.fields",
          "sourcePath": "fields",
          "type": "object",
          "sourceStep": "firebase"
        },
        {
          "targetPath": "algolia.hitCount",
          "sourcePath": "nbHits",
          "type": "number",
          "sourceStep": "algolia"
        },
        {
          "targetPath": "algolia.firstHit",
          "sourcePath": "hits.0.objectID",
          "type": "string",
          "sourceStep": "algolia"
        }
      ]
    }
  },
  "sampleBloatedInput": {
    "requestId": "req_stitch-f",
    "upstreamLatencyMs": 142,
    "audit": {
      "region": "edge",
      "trace": "stitch-firebase-with-algolia-search"
    },
    "payload": {
      "id": "sample_id",
      "status": "active",
      "nested": {
        "tags": [
          "demo"
        ],
        "internal": true
      },
      "unused_blob": {
        "foo": "bar",
        "bar": "baz"
      }
    }
  },
  "sampleSlimmedOutput": {
    "firebase_docName": "sample",
    "firebase_fields": "sample",
    "algolia_hitCount": "sample",
    "algolia_firstHit": "sample"
  },
  "curlSnippet": "curl -X POST \"https://realcomposer.com/v1/workspace/stitch-firebase-with-algolia-search\" \\\n  -H \"Authorization: Bearer rc_live_client_token\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"model\":\"example\"}'",
  "faqs": [
    {
      "question": "Which Firebase credential belongs in the vault for this pipeline?",
      "answer": "Log request IDs for stitch-firebase-with-algolia-search, not raw Firebase payloads, because upstream bodies may include PII."
    },
    {
      "question": "What cache key does RealComposer use?",
      "answer": "stitch-firebase-with-algolia-search vault headers attach server-side, but Anthropic or OpenAI model and messages must come from the client body."
    },
    {
      "question": "How do I rotate upstream credentials?",
      "answer": "Allowed origins on the stitch-firebase-with-algolia-search client token restrict which domains may call the edge URL."
    }
  ],
  "relatedRecipeSlugs": [
    "combine-algolia-search-with-user-favorites",
    "combine-openai-and-supabase-vector-search"
  ],
  "updatedAt": "2026-11-20",
  "links": {
    "page": "https://realcomposer.com/recipes/stitch-firebase-with-algolia-search",
    "markdown": "https://realcomposer.com/recipes/stitch-firebase-with-algolia-search.md",
    "json": "https://realcomposer.com/recipes/stitch-firebase-with-algolia-search.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=stitch-firebase-with-algolia-search&via=agent"
  }
}