A Firebase Extension that automatically deploys Typesense on a Compute Engine VM and syncs your Firestore data for full-text search.
- One-click installation: Deploy Typesense with a single command
- Auto-sync: Firestore documents are automatically indexed when created, updated, or deleted
- Low cost: ~$7-14/month for the VM (persistent, doesn't scale to zero)
- Persistent storage: Data survives VM restarts via attached persistent disk
- Client access: External IP allows direct search from web/mobile apps
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Firestore │────▶│ Cloud Function │────▶│ Compute Engine │
│ (write) │ │ (onWrite) │ │ VM (Typesense) │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│
▼
┌───────────────┐
│ Persistent │
│ Disk (/data) │
└───────────────┘
| Machine Type | RAM | Monthly Cost |
|---|---|---|
| e2-micro | 1 GB | ~$7 |
| e2-small | 2 GB | ~$14 |
| e2-medium | 4 GB | ~$28 |
Plus:
- Persistent disk: ~$0.04/GB/month
- External IP: ~$3/month (for direct client access)
- Secret Manager: ~$0.03/month
-
Enable required APIs:
gcloud services enable compute.googleapis.com secretmanager.googleapis.com --project=YOUR_PROJECT -
Grant IAM permissions (one-time setup):
PROJECT_NUMBER=$(gcloud projects describe YOUR_PROJECT --format="value(projectNumber)") gcloud projects add-iam-policy-binding YOUR_PROJECT \ --member="serviceAccount:service-${PROJECT_NUMBER}@gcp-sa-firebasemods.iam.gserviceaccount.com" \ --role="roles/resourcemanager.projectIamAdmin"
firebase ext:install . --project=YOUR_PROJECT| Parameter | Description |
|---|---|
VM_ZONE |
Zone for the Typesense VM |
TYPESENSE_MACHINE_TYPE |
VM size (e2-micro, e2-small, e2-medium) |
DISK_SIZE_GB |
Persistent disk size in GB |
COLLECTIONS_TO_INDEX |
Firestore collections to sync |
import { getFunctions, httpsCallable } from "firebase/functions";
const getSearchConfig = httpsCallable(getFunctions(), "ext-typesense-search-getSearchConfig");
const { data } = await getSearchConfig();import Typesense from "typesense";
const client = new Typesense.Client({
nodes: [{ host: data.host, port: data.port, protocol: data.protocol }],
apiKey: data.apiKey,
});
const results = await client.collections("products").documents().search({
q: "search query",
query_by: "name,description",
});curl -X POST -H "Authorization: Bearer TOKEN" \
https://REGION-PROJECT.cloudfunctions.net/ext-typesense-search-backfillPublish the extension with:
firebase ext:dev:upload firecms/typesense-search --repo=https://github.com/firecmsco/typesense-extension --root=.
Apache-2.0