wealth/docs/decisions/0021-channel-feed-starts-fr...

1.4 KiB

0021 A channel's feed starts from the server's first page as initial data

Status: Superseded by 0070 · Area: architecture · Date: 2026-10-07 · Decided by: agent

Context

The channel feed and the post page must be in the server HTML for search and first paint, stay live in the browser (older pages, edits, deletes, a subscriber's unlocked posts), and the platform can't reach the app's per-request getQueryClient() to prefetch and dehydrate.

Decision

  • The server reads the first page (or the post) through its cache and passes it as a prop; the client part's model uses it as the query's initialData (postKeys.channelFeed, postKeys.detail).
  • The server read carries no session, so premium posts arrive locked. When the viewer is the creator or an active subscriber, the model reads the loaded pages again in the browser and the posts open in place; until then their gates show the pending skeleton.
  • Mutations update these queries in place (replaceCachedPost, removeCachedPost); a new post drops the channel's query so its next visit starts from a fresh server page.

Alternatives

  • Query hydration with HydrationBoundary (the skill's default for live data): not chosen; it needs the app's query client inside a platform server organism.

Consequences

A cached feed outlives a later server render of the same channel until it is invalidated, so every action that changes a channel's posts must update or drop postKeys.channelFeed.