The easiest Firebase API
One class for Firestore, Realtime Database, Storage, and Auth. Client hooks, Admin SDK, and Next.js env vars — without the boilerplate.
bun add refirebasenpm install refirebasepnpm add refirebaseyarn add refirebaseGetting started
Pass config or read FIREBASE_* / NEXT_PUBLIC_FIREBASE_*. Same verbs on client and server.
import { Refirebase } from 'refirebase';
const { db, auth } = new Refirebase();
const users = await db.firestore.get('users', {
where: { role: 'admin' },
orderBy: [{ field: 'created_at', direction: 'desc' }],
limit: 20,
});
const stop = db.firestore.subscribe(
'conversations/abc/messages',
(messages) => console.log(messages),
);
// google
await auth.handleProviderSignIn('google');
// better auth
await auth.handleCustomTokenSignIn(serverToken);
// sign out
await auth.handleSignOut();
const uploaded = await db.storage.upload(
'media/photo.jpg',
file,
);
const bytes = await db.storage.getBytes(uploaded.path);
import { RefirebaseAdmin } from 'refirebase/admin';
const admin = new RefirebaseAdmin();
const token = await admin.auth.createCustomToken(userId);
await admin.db.storage.upload('media/photo.jpg', buffer);
const url = await admin.db.storage.getSignedUrl(
'media/photo.jpg',
{ expiresSeconds: 60 },
);
import {
RefirebaseProvider,
useCollection,
useUser,
} from 'refirebase/react';
function Inbox() {
const { user } = useUser();
const { data } = useCollection('messages', {
where: { to: user?.uid },
});
return <ul>{data.map((m) => <li key={m.id}>{m.text}</li>)}</ul>;
}
Features
A thin, typed API over the Firebase products you already use.
One-line queries
get, add, set, update, delete — plus where, orderBy, and limit without building Query objects.
Live updates
Firestore subscribe and Realtime onValue, with onDisconnect for presence.
Auth that fits Next.js
Google popup, email/password, and custom tokens so Better Auth sessions can unlock Firebase rules.
Admin, same shape
refirebase/admin mirrors the client: transactions, signed URLs, createCustomToken.
Schema generics
Pass a TypeScript schema and collection names autocomplete with the right document type.
Next.js env
Reads FIREBASE_* and NEXT_PUBLIC_FIREBASE_* so the client bundle stays valid.
Covers the Firebase surface
One package instead of wiring each SDK yourself.