Skip to content

TypeScript interfaces generated for each PocketBase collection.

pbkit generates types.gen.ts containing TypeScript types for every non-excluded collection.

Every collection gets four types:

The full record shape as returned by the PocketBase API. Extends BaseRecord (or AuthRecord for auth collections).

export interface BaseRecord {
id: string
created: string
updated: string
collectionId: string
collectionName: string
}
export interface AuthRecord extends BaseRecord {
email: string
emailVisibility: boolean
verified: boolean
}
export type ArticlesRecord = BaseRecord & {
title: string
content?: string
status: "draft" | "published" | "archived"
tags?: ("technology" | "design" | "business")[]
author: string
views?: number
}

Fields accepted when creating a new record. Includes password for auth collections but excludes auto-managed fields (id, created, updated).

export type ArticlesCreate = {
title: string
content?: string
status: "draft" | "published" | "archived"
tags?: ("technology" | "design" | "business")[]
author: string
views?: number
}

A partial version of XxxCreate — all fields are optional.

export type ArticlesUpdate = Partial<ArticlesCreate>

A union of valid expand paths for the collection (only generated if the collection has relations).

export type ArticlesExpand = "author" | "categories"
export type CommentsExpand = "article" | "article.author" | "article.categories" | "author"

The expand depth is controlled by types.expandDepth (default: 2).

A CollectionName union of all collection names is also generated:

export type CollectionName = "users" | "categories" | "articles" | "comments"
  • password fields are included in Create types but excluded from Record types
  • autodate fields are excluded from both Record and Create
  • id (primary key) is excluded from Create
  • System fields like email, emailVisibility, verified on auth collections are included in Record but excluded from Create

When a select field has defined values, pbkit generates a literal union:

// Single select
status: "draft" | "published" | "archived"
// Multi-select
tags?: ("technology" | "design" | "business")[]

If no values are defined, it falls back to string or string[].