TypeScript & JavaScript SDK
Install the official JavaScript SDK:
pnpm add pocketbasenpm install pocketbaseyarn add pocketbaseInitializing the Client
import PocketBase from 'pocketbase';
export const pb = new PocketBase('https://<your-subdomain>.pocket-kit.naftalmatoya.tech');
// Auto-cancellation can be disabled if running concurrent requests in React:pb.autoCancellation(false);Authentication & CRUD Operations
// 1. Password Authenticationconst authData = await pb.collection('users').authWithPassword('user@example.com', 'password123');
// 2. Fetch Paginated Recordsconst resultList = await pb.collection('posts').getList(1, 20, { filter: 'created >= "2026-01-01" && active = true', sort: '-created',});
// 3. Create a Recordconst newPost = await pb.collection('posts').create({ title: 'Hello from Pocket Kit', content: 'PocketBase single-tenant cloud deployment.', views: 1,});
// 4. Realtime Subscriptions (SSE)pb.collection('posts').subscribe('*', function (e) { console.log('Realtime event action:', e.action); console.log('Record data:', e.record);});