Firebase code on Sovaria
Run Firestore (modular), Auth, Storage and callable-function code on Sovaria in every SDK: the same documents, queries, snapshots, batches, transactions and field transforms; how rules, auth and storage map.
Sovaria's document collections have Firestore's model — collections, documents, subcollections, queries with cursors, live snapshots, batched writes, transactions and field transforms — and every SDK has Firebase's API for them. Move the data with Migrate from Supabase or Firebase; then change imports, not code.
import { createClient } from '@sovaria/sdk'
import { getFirestore, collection, doc, query, where, orderBy, limit, startAfter, onSnapshot,
getDocs, setDoc, updateDoc, addDoc, writeBatch, runTransaction, serverTimestamp, increment, arrayUnion } from '@sovaria/sdk/firestore'
const sovaria = createClient(SOVARIA_URL, SOVARIA_ANON_KEY)
const db = getFirestore(sovaria)
const q = query(collection(db, 'rooms', roomId, 'messages'), where('hidden', '==', false), orderBy('sentAt'), limit(50))
const stop = onSnapshot(q, (snap) => snap.docChanges().forEach((c) => render(c.type, c.doc.data())))
await addDoc(collection(db, 'rooms', roomId, 'messages'), { text, sentAt: serverTimestamp() })
await updateDoc(doc(db, 'rooms', roomId), { count: increment(1), members: arrayUnion(userId) })| Firebase | Sovaria |
|---|---|
Firestore collection / doc / getDoc(s) / setDoc (merge) / addDoc / updateDoc / deleteDoc | The same names (Firebase-style code (Firestore API)). |
where / orderBy / limit / limitToLast / startAt / startAfter / endAt / endBefore, or() / and() | The same (Querying documents). |
onSnapshot with docChanges() and metadata | The same, over Sovaria's live listeners (Live listeners). |
writeBatch, runTransaction | The same; transactions retry when a document they read changed (Transactions, batches and field transforms). |
serverTimestamp, increment, arrayUnion, arrayRemove, deleteField | The same field transforms. |
getCountFromServer, sum, average, findNearest | The same aggregates and vector search (Vector search on documents). |
| Security rules | Collection rules: who may read and write which documents, checked on every call (How access is decided). |
signInWithEmailAndPassword(auth, e, p) / onAuthStateChanged | sovaria.auth.signInWithPassword({ email: e, password: p }) / onAuthStateChange (Email and password). |
uploadBytes(ref(storage, path), file) / getDownloadURL | sovaria.storage.from(bucket).upload(path, file) / getPublicUrl or createSignedUrl (Working with files). |
httpsCallable(functions, 'f')(data) | sovaria.functions.call('f', data) (Deploying and running functions). |
| Firebase Remote Config, Analytics, Crashlytics | sovaria.config, sovaria.analytics, sovaria.crashes (Product analytics). |