Installation
Add @workorder-systems/sdk to get a typed client over the project’s public views and RPCs. The package ships compiled dist/ output and declarations, with no compile step in your app.
Install the package
Install
npm install @workorder-systems/sdk @supabase/supabase-js
Peer dependency
Install @supabase/supabase-js alongside the SDK (peer range ^2.39.0). The SDK builds on the Supabase client; your app supplies both packages.
Create a client
Pass the project URL and anon key from Project Settings → API:
import { createDbClient } from '@workorder-systems/sdk'
const client = createDbClient(
process.env.SUPABASE_URL!,
process.env.SUPABASE_ANON_KEY!
)
// client.supabase: typed Supabase client
// client.setTenant(tenantId) / client.clearTenant()
// Domain resources (see package README for method lists):
// client.tenants, client.workOrders, client.assets, client.locations, client.spaces, client.departments,
// client.meters, client.plugins, client.authorization, client.catalogs, client.pm, client.dashboard,
// client.audit, client.tenantApiKeys, client.labor, client.scheduling, client.costs, client.projects,
// client.partsInventory, client.safetyCompliance, client.mobile, client.mapZones, client.fieldOps
Same pattern works in the browser and in Node. For edge runtimes (Cloudflare Workers, Vercel Edge, etc.), pass the platform fetch and turn off session persistence if you do not need it:
const client = createDbClient(url, anonKey, {
global: { fetch },
auth: { persistSession: false },
})
Edge runtimes
Use global: { fetch } so requests use the host runtime. Use auth: { persistSession: false } when there is no durable session store. For custom storage, set auth.storage (Supabase-compatible session storage).
Environment variables
The SDK expects SUPABASE_URL and SUPABASE_ANON_KEY in the environment you run it in. Deployed Edge Functions get all SUPABASE_* values from Supabase automatically. See Configuration.