Skip to content

Client

Client

The client is the typed surface every app, automation, and remote uses to read, write, and invoke. It is imported from $bolt/client and generated by bolt sync, so every call is type-checked against your collections.

One client, three surfaces

The client exposes everything your workspace can do through three surfaces:

SurfaceUse it for
client.dbreads and writes — live queries against the local replica, optimistic mutations, and offline queuing
client.invokeremote functions — typed query and command handlers discovered from src/functions/
client.automations— start a declared automation in the background and watch its durable run, or approve a pending approval

The client in action

The same client powers every app — reads, writes, and invokes all flow through it:

import { client } from '$bolt/client';

// Live read — against the local replica, reactive to the change feed
const sites = client.db.sites.findMany({
  where: { status: { eq: 'active' } },
  orderBy: { name: 'asc' },
  limit: 25
});

// Declarative write — Promise<void>; completion invalidates affected live queries
await client.db.site_visits.mutate({
  site_id: siteId,
  visited_at: new Date()
});
client.db.site_visits.pending; // numeric in-flight count

// Remote function — typed query or command handler
const forecast = await client.invoke.holiday_feed({ year: 2026 });

Live data

Reads are live queries against a policy-scoped local replica; browser writes use each collection’s declarative mutate(values) surface, which returns Promise<void>, and numeric pending count.

AI

Model access flows through the ai facility — the host binds the provider, and tenant code never sees credentials.

Boundaries

  • The client never talks to server-side cache APIs.
  • Apps cannot reach private runtime facilities.
  • The generated client is the only sanctioned data path into a workspace.