Getting Started

Quick Start

Create a client and perform your first writes.

This page shows the minimum code needed to start using @frappes/firebase.

1) Create Firebase Firestore port

Use the built-in adapter helper:

firestore-port.ts
import { getFirestore } from "firebase/firestore"
import { createFirebaseFirestorePort } from "@frappes/firebase"

const db = getFirestore()
export const firestore = createFirebaseFirestorePort(db)

2) Create the core client

client.ts
import { createFirestoreCoreClient } from "@frappes/firebase"
import { firestore } from "./firestore-port"

export const client = createFirestoreCoreClient({
  firestore,
  tenantId: "tenant_athens",
  locationId: "loc_syntagma",
  actor: { uid: "manager_1", deviceId: "pos_3" },
})

3) Write your first order

first-order.ts
import { client } from "./client"

const result = await client.createOrder({
  source: "in_store",
  channel: "pos",
  totals: { subtotal: 10, tax: 2.4, discounts: 0, total: 12.4 },
  items: [{ productId: "espresso", nameSnapshot: "Espresso", qty: 1, unitPriceSnapshot: 10 }],
  idempotencyKey: "ord-pos-0001-create",
})

console.log(result.orderId, result.eventId)
Copyright © 2026