Skip to content

The generated files

What types.gen.ts, client.gen.ts, and sdk.gen.ts each do, and why pbkit splits them.

A default run writes three files into your output directory. They are split by responsibility, and knowing which is which tells you what to import and what to leave alone.

FileResponsibilityYou import from it
types.gen.tsPure TypeScript types — no runtime codeYes, for type annotations
client.gen.tsA single configured PocketBase client instanceRarely — directly only for advanced cases
sdk.gen.tsTyped CRUD functions that use the clientYes, for every data call

The split mirrors the boundary between types and runtime code.

types.gen.ts contains only type/interface declarations, so it is erased at build time and can be imported with import type from anywhere — including environments where you would never want a PocketBase client (shared packages, edge configs, test fixtures).

client.gen.ts is the one place a concrete client is instantiated, using your sdk.baseUrl. Isolating it means there is exactly one client to configure or replace, and the type-only file stays free of runtime imports.

sdk.gen.ts is the runtime surface you actually call. It depends on both of the other files: it uses the types for its signatures and the client to make requests. Each function also accepts a per-call client override, so you are never locked into the singleton — see Generated SDK.

Plugins add their own *.gen.ts files (such as tanstack.gen.ts or zod.gen.ts) alongside these, following the same convention.

The output directory is cleared and rewritten on every run. That has two consequences:

  • Never edit a .gen.ts file by hand — your changes will be lost on the next generate. Put custom logic in your own modules that import from the generated SDK.
  • Re-generate whenever the schema changes. The files are a snapshot of the schema at generation time; the --watch flag keeps them current during development.

Whether you commit the generated files or generate them in CI is your choice. Committing them makes diffs reviewable and builds reproducible without a live PocketBase; generating in CI keeps them guaranteed-fresh. Either works because generation is deterministic for a given schema.