Generate TypeScript types from your PocketBase collections in seconds.
- Clone the repository
cd pocketbase-types-generator
npm install
- Export your pocketbase schema using the
export
option on the Admin in your pocketbase db. - Place the file in the current folder.
- Rename the file to
schema.json
- Open the terminal and run
npm run generate
- The script will generate the file
pb.types.ts
in the current folder - Copy the
pb.types.ts
to your project
This creates pb.types.ts
with interfaces for all your collections:
interface Base {
id: string;
created: string;
updated: string;
}
interface User extends Base {
name: string;
avatar: string;
post_id: string;
}
interface Post extends Base {
title: string;
content: string;
author_id: string
}
- Generates TypeScript interfaces from PocketBase collections
- Supports all PocketBase field types
- Excludes views by default
- Adds proper nullability
- Supports custom fields
MIT © thisuxhq