Feeds
search ranks rows by "closest to my query." query returns exact matches
from your source. Feeds are different again: a declarative ranking
primitive that turns a lens into a paginated, optionally live-updating stream.
Each feed is declared under feeds.<name> and granted under
grants.feed.<name>.
One config block becomes:
- A typed Beam method —
beam.<lens>.feed.<name>(params)returns one page - A WebSocket subscription —
.subscribe()yieldsfeed.tickevents - A debug endpoint —
.explain({ recordId })returns per-scorer math (sk-only) - A React hook —
useFeed(handle, { context, liveUpdates })
See feeds in action at demo.semilayer.com/feeds — three feeds on one lens (discover / latest / related), rendered with useFeed and live WS ticks.
Three patterns from one primitive
A single lens can host as many named feeds as you want. The canonical shapes:
- Discover — algorithmic.
similarityto user context +recency+engagement. Powers the "for you" tab. - Latest — chronological.
recency-only. Powers the "newest" tab.candidates: { from: 'recent' }. - Related —
similarity.against: { mode: 'recordVector' }. The seed is a single clicked record's existing vector. Powers "more like this." Zero embedding API cost.
One lens, one set of vectors, three named feeds — each gets its own typed method, access rule, pagination, and scorer mix.
The building blocks
Every feed has the same structure:
Every field is typed in @semilayer/core's FeedConfig — the Beam codegen
produces per-feed methods with full inference.
Access rules
Feed access is per-named-feed. Add to grants.feed:
Feeds without an explicit grant default to deny for pk_ keys. sk_ keys
bypass. No accidental exposure.
Where to start
- Quickstart — add a feed, push, render with
useFeedin under 5 minutes. - Ranking — every scorer with worked math and valid tokens.
- Signals (your data) — engagement reads through a sibling lens, personalization context.
- Related items — the
recordVectorpattern in ~12 lines. - Live evolution — WS subscribe + the
feed.tickcontract. - Pagination & dedup — cursor,
seenWindow,withinmodes. - Explain — per-scorer math for "why is this ranked here?"
- Caching — BYO FeedCache with five built-in adapters.
- Recipes — short configs for common feed types.