MongoDB
One Express route, a handful of concurrent Mongoose queries, and a single JSON response that flux.bootstrap() reads in one network call per scope — with the ObjectId-to-string conversion every Mongo-backed channel needs.
- A running MongoDB instance and Mongoose (or the native driver — examples here use Mongoose) wired into a Node backend
- A replica set (or Atlas, which is one by default) if you plan to use change streams for realtime — see Step 5
- Familiarity with api/bootstrap on the client side
A basic bootstrap route
{ ok, data, assets }. Keys inside data must exactly match the map object in your client-side flux.bootstrap() call — and every document needs its _id normalized before it goes out, covered next.ObjectId → string, every time
Section 4.1's FluxNormalizedEvent interface types id as string — apply the same normalizeId() helper on your realtime adapter's change events (Step 5) as you do here on the bootstrap response, so an item's id is identical whether it arrived via bootstrap or realtime.
One network call, not one query
A 'user'-scope endpoint
'user'-scope bootstrap call is a separate endpoint from the 'global' one (Section 4.13). Filter every query by a plain string userId field resolved from your own auth middleware — never a value read out of the request.A Mongoose ref resolves to an ObjectId unless explicitly .populate()'d and stringified. Storing userId as a plain string on each document keeps the query filter and any later equality checks against req.user.id consistent everywhere.
Delta catch-up and live updates with change streams
FluxChangelog collection via queryChangesSince() so offline deletions and sparse field updates are captured properly. For live forward events, MongoDB change streams stream sparse field updates directly to connected sockets:Backing a handshake replay strategy
replayStrategy: 'handshake', you need a separate revalidation endpoint — this is what revalidateFn calls, once per endpoint group, with the full manifest of queued entries.What not to do
For Postgres, see bootstrap/postgres. For a framework-agnostic Node reference (including assets[] chunk warming for Next.js), see bootstrap/node. For any other backend language, see bootstrap/rest. For the client-side call this endpoint answers, see api/bootstrap.