Documentation
Type-safe Firestore models for TypeScript — one modeling core across Node, Express, Next.js, and React.
Fireclass turns Firestore documents into type-safe TypeScript classes. Define a
model once and get typed CRUD, typed queries, validation, and — on the client —
realtime hooks. One modeling core powers every runtime, so the API is identical
whether you're on the server with firebase-admin or in the browser with the
Firebase client SDK.
import { Collection } from "@dharayush7/fireclass-js";
import { IsEmail, IsInt, Min } from "class-validator";
import { BaseModel } from "../lib/fireclass";
@Collection("users")
export class User extends BaseModel<User> {
@IsEmail() email!: string;
@IsInt() @Min(0) age!: number;
constructor(data?: Partial<User>) {
super(data);
Object.assign(this, data);
}
}
const id = await new User({ email: "ada@example.com", age: 36 }).save();
const adults = await User.findMany({ where: { age: { gte: 18 } } });One suite, five packages
Install just what your framework needs — or let the CLI pick. Every package is
built on the shared @dharayush7/fireclass-core.
| Package | Runtime | For |
|---|---|---|
@dharayush7/fireclass-core | none (pure TS) | the shared modeling core |
@dharayush7/fireclass-js | firebase-admin | Node / Express |
@dharayush7/fireclass-ssr | firebase-admin | Next.js (App Router) |
@dharayush7/fireclass-react | firebase client SDK | React (realtime hooks) |
@dharayush7/fireclass-cli | Node CLI | scaffolding & setup |
class-validator decorators run on every save(), surfacing a typed ValidationFailedError.useQuery and useDoc subscribe via onSnapshot and re-render on every change.server-only models, a memoized admin singleton, and an RSC serialization bridge.npx fireclass init detects your framework and wires everything up.