Documentation
Detect the framework, configure Firebase paths, install dependencies, and scaffold a Fireclass project.
init is the only command that can create fireclass.json. It detects the
project environment, asks for framework-specific paths, scaffolds missing files,
and optionally installs dependencies.
fireclass init [options]Complete the Firebase prerequisites before running the command. React and Express projects should prepare their recommended Firebase entry first; the CLI references an existing file without overwriting it.
| Option | Description |
|---|---|
-y, --yes | Run non-interactively with detected or supplied defaults. |
--framework <framework> | Force next, react, or express. |
--pm <manager> | Force pnpm, yarn, bun, or npm. |
--skip-install | Scaffold configuration and files without installing dependencies. |
-h, --help | Print command help. |
The CLI walks upward from the current directory and selects the nearest folder
containing package.json.
Framework detection reads dependencies and devDependencies in this order:
next → Next.jsexpress → Express / Node.jsreact plus react-dom → ReactNext.js wins over React because Next projects also declare React.
In interactive mode, the detected framework is only the initial selection. With
--yes, detection must succeed unless --framework is supplied.
Detection checks:
packageManager field in package.json.pnpm-lock.yaml, yarn.lock, bun.lockb / bun.lock, then
package-lock.json.Interactive mode lets you change the result. --yes falls back to npm when no
manager is detected.
The command asks for:
Projects with a src directory default to:
src/lib/firebase.ts
src/lib/fireclass.ts
src/modelsProjects without src default to:
lib/firebase.ts
lib/fireclass.ts
modelsFor Firebase exports, enter a value such as db or a factory such as
getDb(). The trailing parentheses are stored as factory: true and make
the generated entry call the function.
| Framework | SDK | Firebase behavior |
|---|---|---|
| Next.js | @dharayush7/fireclass-ssr | No Firebase file; credentials come from environment variables or ADC. |
| React | @dharayush7/fireclass-react | Uses the Firebase client SDK and defaults to a db export. |
| Express | @dharayush7/fireclass-js | Uses Firebase Admin and defaults to a lazy getDb() factory. |
Every framework also installs class-validator, class-transformer, and
reflect-metadata. React adds firebase; Express adds firebase-admin;
Next.js adds firebase-admin and server-only.
init writes or manages:
fireclass.json with the public schema URL, CLI version, framework,
package manager, SDK, paths, and exports.BaseModel,
adapter, and React hooks where applicable.todo.ts model when it is missing..env.local and .env.example, or Express .env.example..env.local or .env.The Fireclass entry does not re-export decorators or helpers. Generated models
import Collection from the runtime SDK and BaseModel from the local entry.
fireclass.json is displayed before interactive reconfiguration;
answering no leaves the project untouched.--yes re-runs configuration without the confirmation prompt, rewrites
fireclass.json, and still skips an existing Fireclass entry.Review --yes in configured projects
--yes is intended for automation. Supply --framework and --pm when
the project cannot be detected reliably, and review any path changes in the
rewritten configuration.
npx fireclass initnpx fireclass init --yes --framework react --pm pnpmnpx fireclass init --yes --framework express --pm npm --skip-installAfter --skip-install, install the dependencies reported by the CLI before
running doctor.
The command exits non-zero when:
package.json exists or it cannot be parsed.--yes cannot detect a framework and none was supplied.Cancelling an interactive prompt exits immediately without continuing the remaining setup.