CLI
typebase-io-cli init
Scaffold a new Typebase project structure.
Last updated on
Scaffold a new Typebase project structure.
npx typebase-io-cli initCreates a typebase/ directory with:
tsconfig.json: TypeScript configdb/schema.ts: example database schemadb/relations.ts: example relationsactions/queries/todos.ts: example query actionsactions/mutations/todos.ts: example mutation actionsenv.ts: an empty env schema with a commented-out example key_generated/: auto-generated type files
It also creates a typebase.json at the project root if there isn't one, holding just a $schema reference so your editor
autocompletes the config as you fill it in. Every option stays on its default until you set it. Running init over an existing typebase.json keeps
the values already in it.
Options
| Flag | Description |
|---|---|
-f, --force | Overwrite tsconfig.json and regenerate the scaffolded example files. |
--with-auth | Include an example auth.ts with email/password authentication. |
--with-db-publisher | Include a publisher.ts, the events table it needs, and actions that use it. |
--skip-example | Skip generating the example schema, actions, and env.ts. |
--with-auth
Sets up authentication with better-auth, using email and password. On top of the usual scaffold it writes:
auth.ts: adefineAuthconfig withemailAndPasswordenabled andhttp://localhost:3000trusteddb/schema.ts: theusers,sessions,accounts, andverificationstables better-auth needsdb/relations.ts: those tables registered, plus the relations between them andtodosactions/custom-actions.ts: anauthedActionthat rejects requests without a valid sessionactions/queries/todos.tsandactions/mutations/todos.ts: built onauthedAction, and scoped to the signed-in user
It cannot be combined with
--skip-example, which skips the example this flag adds to.--with-db-publisher
Sets up a publisher, so actions can publish events and stream them to clients. On top of the usual scaffold it writes:
publisher.ts: adbpublisher declaring one example event,todo.createddb/schema.ts: theeventstable the publisher keeps events indb/relations.ts: anevents: {}entry registering that tableactions/mutations/todos.ts:createpublishestodo.createdafter insertingactions/queries/todos.ts:getManybecomes a streaming action that re-sends the list on every new todo
It cannot be combined with
--skip-example, which skips the example this flag adds to.