Generate Beam
The Beam client is a typed TypeScript module generated from your sl.config.ts.
It gives you a fully-typed API surface that matches your exact lens definitions —
no casting, no magic strings.
Generate
This reads your sl.config.ts and writes the generated module to
./generated/semilayer/ by default:
Custom output directory
Commit the generated directory to version control. Re-run semilayer generate
after every sl.config.ts change.
Initialize the Client
The createBeam factory is lightweight — call it once and reuse the instance.
With a user token (RBAC)
For per-user access rules (e.g. a public pk_ key with row-level restrictions):
Using the Client
The beam instance has one property per lens, each with the full set of operations.
Search
Similar
Query
Direct filtered read from the source. Requires facets.query enabled in the lens config.
Streaming search
Results stream as they arrive — useful for large result sets or low-latency UIs:
Live tail
Subscribe to every insert, update, and delete on a lens in real time:
Observe
Watch a single record — get the current state immediately, then receive every subsequent change:
TypeScript Types
The generated types.ts exports one metadata type per lens:
These types are derived directly from your field declarations in sl.config.ts.
If you add or rename a field, regenerate and TypeScript will surface everywhere
that needs updating.
In a Framework
Next.js (App Router)
Client-side (public key)
Next Steps
- Querying — deep dive into all query operations
- Auth & RBAC — per-user access rules with user JWTs
- Examples — working code examples