pbkit.config.ts is the main configuration file. It must export a PbkitConfig object as the default export.
import type { PbkitConfig } from "@karnak19/pbkit"
export default { input: "https://my-pb.example.com", output: "./src/generated", sdk: { baseUrl: "https://my-pb.example.com", },} satisfies PbkitConfigRequired. The schema source. Can be:
- A URL string — fetches collections from a live PocketBase API
- A file path string — reads an exported JSON schema
- An object with
urland optionaltoken— authenticated API access - An object with
file— explicit file path
// Live APIinput: "https://my-pb.example.com"
// Authenticated APIinput: { url: "https://my-pb.example.com", token: "admin-token" }
// JSON fileinput: "./pb_schema.json"output
Section titled “output”Required. Directory where generated files are written. The directory is cleared and recreated on each run.
output: "./src/generated"Type generation options.
types: { // Represent dates as strings (true) or Date objects (false) // Default: true dateStrings: true,
// Add | null to optional fields // Default: false nullableFields: false,
// Which fields get the ? (optional) marker // "required-only" — only fields marked required in PocketBase are non-optional // "all" — all fields are optional // Default: "required-only" optionalFields: "required-only",
// Max depth for expand type unions (e.g. "author", "author.comments") // Default: 2 expandDepth: 2,}SDK generation options.
sdk: { // Set to false to skip SDK generation entirely // Default: true (always generated) enabled: true,
// Custom import path for the PocketBase library // Default: "pocketbase" pbImport: "pocketbase",
// Base URL used by the generated client in client.gen.ts // Default: "" baseUrl: "https://my-pb.example.com",
// Custom import path for the generated types // Default: "./types.gen" typesImport: "./types.gen",}collections
Section titled “collections”Per-collection configuration. See the Collections page for details.
collections: { _superusers: { exclude: true }, articles: { operations: { create: false, delete: false } },}plugins
Section titled “plugins”Array of pbkit plugins. See the Plugins section.
plugins: []Full example
Section titled “Full example”import type { PbkitConfig } from "@karnak19/pbkit"
export default { input: "https://my-pb.example.com", output: "./src/generated",
types: { dateStrings: true, nullableFields: false, optionalFields: "required-only", expandDepth: 2, },
sdk: { enabled: true, pbImport: "pocketbase", baseUrl: "https://my-pb.example.com", },
collections: { _superusers: { exclude: true }, logs: { exclude: true }, articles: { operations: { create: false, delete: false } }, },
plugins: [],} satisfies PbkitConfig