Skip to content

TypeScript SDK

The core TypeScript SDK works with any web framework. Framework-specific bindings (Angular, React, Vue) build on top of this.

Terminal window
npm install @pulsabase/sdk
import { PulsaClient } from '@pulsabase/sdk';
const pb = new PulsaClient({
url: 'https://api.yourproject.pulsabase.io',
clientKey: 'your-public-client-key',
auth: { autoRefreshToken: true },
});
// Fetch all users
const users = await pb.from('users').find();
// Filtered query
const adults = await pb.from('users')
.where('age', { $gte: 18 })
.orderBy('name', 'asc')
.limit(10)
.find();
// Insert
const newUser = await pb.from('users').insert({
name: 'Alice',
email: 'alice@example.com',
});
// Update
await pb.from('users')
.where('id', userId)
.update({ name: 'Alice Smith' });
// Delete
await pb.from('users')
.where('id', userId)
.delete();
// Sign up
await pb.auth.signUpWithPassword('user@example.com', 'securePassword');
// Sign in
await pb.auth.signInWithPassword('user@example.com', 'securePassword');
// Current user
const user = await pb.auth.getUser();
// Subscribe to table changes
pb.from('messages')
.where('channel_id', channelId)
.subscribe('INSERT', (message) => {
console.log('New message:', message);
});
// Custom channels
const channel = pb.channel('typing-indicators');
channel.on('typing', (data) => console.log(data));
channel.send('typing', { userId: '123' });
// Upload a file
const file = document.getElementById('file-input').files[0];
await pb.storage.upload('user-123/profile.jpg', file);
// Get a presigned download URL
const url = await pb.storage.getDownloadUrl('user-123/profile.jpg');