Ingestion Strategies
SNAPSHOT ingestion
The simplest of Flux's four ingestion types — for a channel that is always exactly one object. No array handling, no byte-budget eviction, no pagination — just cache it, hydrate it, and replace it wholesale on every update.
Prerequisites
- A store already registered via register() — see api/register
- Familiarity with the other three types — see ingestion/collection-all, ingestion/lru, ingestion/paginated
1
Basic usage
Set
ingestionType: 'SNAPSHOT' on any channel whose data is a single object rather than a collection.typescript
2
What qualifies as a SNAPSHOT
Anything that's always exactly one object and never grows into a list — page content, site-wide config, a legal document.
typescript
3
How it's cached
SNAPSHOT is the most direct of the four types in IDB — the object goes straight into a single TTL envelope under the channel's
idbKey, with none of the per-item key splitting or eviction accounting that LRU channels require.typescript
4
The same dispatch path, every time
A SNAPSHOT channel is dispatched identically regardless of which of the three data paths produced it — cold IDB boot, a bootstrap fetch, or a live realtime event.
typescript
5
Realtime updates replace the object wholesale
There's no partial-merge behavior for SNAPSHOT channels — whatever object a realtime event carries in
event.data is handed to the same hydrateState function bootstrap and IDB hydration use.typescript
Send the full object from your backend
Since Flux doesn't merge partial diffs for SNAPSHOT channels itself, make sure your realtime adapter normalizes each event's data field to the complete object, not just the changed fields — the Supabase adapter's partial-diff-vs-full-row handling is covered in adapters/supabase.
6
Choosing the right ingestion type
SNAPSHOT is one of four. Reach for
COLLECTION_ALL the moment your data becomes a bounded array rather than a single object.typescript
For bounded arrays, see ingestion/collection-all. For byte-budget-capped detail pages, see ingestion/lru. For configuring ingestionType alongside the rest of a registration, see api/register.