First class Firebase Admin adapter for Hyper Fetch
npm install @hyper-fetch/firebase-admin---
@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
1. One API – everywhere – share request definitions between the browser and Node.js environments.
2. First-class TypeScript – strong typing for parameters, payloads and responses out of the box.
3. Queue & Retry – leverage Hyper Fetch queueing on top of Firebase Admin SDK.
4. Unified tooling – logging, events and interceptors identical on both sides.
5. Works with Firestore _and_ Realtime Database – pick the storage that fits your use-case.
:::
``bash`
npm install @hyper-fetch/core @hyper-fetch/firebase-admin firebase-adminor
yarn add @hyper-fetch/core @hyper-fetch/firebase-admin firebase-admin
> firebase-admin is a peer dependency and must be installed separately.
`ts
import { initializeApp, applicationDefault } from "firebase-admin/app";
import { getFirestore } from "firebase-admin/firestore";
initializeApp({
credential: applicationDefault(),
});
export const db = getFirestore();
`
`ts
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));
`
`ts
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` |
- Documentation
- API Reference
- Guides
- NPM
We ❤️ contributions! Please read the contributing guide and open an issue or pull request.
---
Made with ☕ by BetterTyped