JavaScript / TypeScript SDK
The JavaScript SDK provides typed clients for every Reactor capability. Install the packages you need, or use @reactor/client as a unified entry point.
Installation
Section titled “Installation”npm install @reactor/client# Or install individual packages:npm install @reactor/auth @reactor/data @reactor/storage @reactor/functionsCreating a client
Section titled “Creating a client”import { createClient } from '@reactor/client';
const reactor = createClient({ url: process.env.REACTOR_URL ?? 'http://localhost:8000', token: process.env.REACTOR_TOKEN,});Browser usage
Section titled “Browser usage”For client-side apps, use the anon key and enable RLS on your tables:
const reactor = createClient({ url: 'https://api.reactor.cloud', token: import.meta.env.VITE_REACTOR_ANON_KEY,});Capability clients
Section titled “Capability clients”Auth — @reactor/auth
Section titled “Auth — @reactor/auth”import { createAuthClient } from '@reactor/auth';
const auth = createAuthClient({ url, token });
// Sign upconst { user, session } = await auth.signUp({ email: 'user@example.com', password: 'secure-password',});
// Sign inconst { session } = await auth.signInWithPassword({ email: 'user@example.com', password: 'secure-password',});
// Get current userconst user = await auth.getUser();Data — @reactor/data
Section titled “Data — @reactor/data”PostgREST-style query builder:
import { createDataClient } from '@reactor/data';
const data = createDataClient({ url, token });
// Selectconst { data: posts } = await data .from('posts') .select('id, title, created_at') .eq('published', true) .order('created_at', { ascending: false }) .limit(20);
// Insertconst { data: newPost } = await data .from('posts') .insert({ title: 'Hello', body: 'World' }) .select() .single();
// Updateawait data.from('posts').update({ published: true }).eq('id', postId);
// Deleteawait data.from('posts').delete().eq('id', postId);Realtime — @reactor/realtime
Section titled “Realtime — @reactor/realtime”import { createRealtimeClient } from '@reactor/realtime';
const realtime = createRealtimeClient({ url, token });
const channel = realtime.channel('posts');
channel.on('postgres_changes', { event: 'INSERT', schema: 'public', table: 'posts',}, (payload) => { console.log('New post:', payload.new);});
await channel.subscribe();Storage — @reactor/storage
Section titled “Storage — @reactor/storage”import { createStorageClient } from '@reactor/storage';
const storage = createStorageClient({ url, token });
// Uploadawait storage.from('avatars').upload('user-123.png', file);
// Downloadconst { data: blob } = await storage.from('avatars').download('user-123.png');
// Signed URLconst { signedUrl } = await storage .from('avatars') .createSignedUrl('user-123.png', 3600);Functions — @reactor/functions
Section titled “Functions — @reactor/functions”import { createFunctionsClient } from '@reactor/functions';
const functions = createFunctionsClient({ url, token });
const { data } = await functions.invoke('process-order', { body: { orderId: '123' },});Jobs — @reactor/jobs
Section titled “Jobs — @reactor/jobs”import { createJobsClient } from '@reactor/jobs';
const jobs = createJobsClient({ url, token });
await jobs.trigger('send-digest', { userId: 'abc' });AI / Gateway — @reactor/ai
Section titled “AI / Gateway — @reactor/ai”import { createAiClient } from '@reactor/ai';
const ai = createAiClient({ url, token });
const response = await ai.chat.completions.create({ model: 'anthropic/claude-sonnet-4.6', messages: [{ role: 'user', content: 'Hello!' }],});Connect — @reactor/connect
Section titled “Connect — @reactor/connect”import { createConnectClient } from '@reactor/connect';
const connect = createConnectClient({ url, token });
const result = await connect.instances('stripe-main').action('createCustomer', { email: 'customer@example.com',});Error handling
Section titled “Error handling”All SDK methods throw typed errors:
import { ReactorError } from '@reactor/client';
try { await data.from('posts').insert({ title: 'Test' });} catch (err) { if (err instanceof ReactorError) { console.error(err.code, err.message); }}Generated API reference
Section titled “Generated API reference”Auto-generated TypeDoc output for each package is available under the generated docs directory. Regenerate with:
cd platform/apps/reactor-cloud/sites/docsnpm run generate:sdkSource
Section titled “Source”SDK source lives in the monorepo at reactor-cloud/sdks/js/packages/.