@hyper-fetch/firebase-admin
is the official Firebase Admin SDK adapter for
Hyper Fetch. It brings the same declarative, type-safe API you use on the client
to your server or cloud functions.
:::tip Purpose
- One API – everywhere – share request definitions between the browser and Node.js environments.
- First-class TypeScript – strong typing for parameters, payloads and responses out of the box.
- Queue & Retry – leverage Hyper Fetch queueing on top of Firebase Admin SDK.
- Unified tooling – logging, events and interceptors identical on both sides.
- Works with Firestore and Realtime Database – pick the storage that fits your use-case.
:::
npm install @hyper-fetch/core @hyper-fetch/firebase-admin firebase-admin
# or
yarn add @hyper-fetch/core @hyper-fetch/firebase-admin firebase-admin
firebase-admin
is a peer dependency and must be installed separately.
import { initializeApp, applicationDefault } from "firebase-admin/app";
import { getFirestore } from "firebase-admin/firestore";
initializeApp({
credential: applicationDefault(),
});
export const db = getFirestore();
import { createClient } from "@hyper-fetch/core";
import { FirebaseAdminAdapter } from "@hyper-fetch/firebase-admin";
import { db } from "./firebase";
export const client = createClient({ url: "" }).setAdapter(FirebaseAdminAdapter(db));
interface MessagePayload {
text: string;
}
export const addMessage = client.createRequest<{ payload: MessagePayload; response: null }>()({
endpoint: "/messages",
method: "addDoc",
});
await addMessage.send({ payload: { text: "Hello from the server!" } });
Firestore | Realtime Database |
---|---|
getDoc , getDocs
|
get |
setDoc , addDoc
|
set , push
|
updateDoc , deleteDoc
|
update , remove
|
We ❤️ contributions! Please read the contributing guide and open an issue or pull request.
Made with ☕ by BetterTyped