@litewarp/start-relay-network
v1.0.0
Published
TanStack Start adapter for Relay with SSR streaming support
Maintainers
Readme
@litewarp/start-relay-network
TanStack Start adapter for React Relay with SSR streaming support. Supports
@defer and @stream with progressive hydration.
How It Works
- A route loader calls
context.preloadQuery(query, vars). - On the server, the network layer starts the GraphQL fetch and captures every
response in a
ReplaySubjectkeyed by the query. - The
PreloadedQueryis serialized into the router's dehydrated state and sent to the client immediately. - GraphQL responses stream to the client over a custom transport as they arrive, including deferred and streamed payloads.
- The client hydrates the
PreloadedQueryagainst the replayed responses, so no query is fetched twice.
Exports
.--createRelayEnvironment,integrateRelayWithRouter,setupRouterRelayIntegration,createMiddleware, and the public types (src/index.tsx)./transforms/incremental-delivery-- response transform for the GraphQL incremental delivery format (hasNext/incremental)./transforms/grafast-relay-- response transform for the Grafast / PostGraphile v5 incremental delivery format
Key Directories
src/environment.ts-- builds the Relay environment and query registrysrc/network/-- server and client fetch functions with the query cachesrc/cache/-- per-queryReplaySubjectrecordssrc/fetch/-- multipart response parsing and incremental patch resolutionsrc/middleware/-- request and response middleware pipelinesrc/preload/-- server and clientpreloadQueryimplementations and theSerializableExtensionsaugmentation for TanStack's loader type checksrc/transport/-- SSR streaming transport, serialization adapters, and the Relay provider wrappersrc/setup/-- wires the transport and serialization adapters into the router
Peer Dependencies
React 19, react-relay / relay-runtime 21, @tanstack/react-router,
@tanstack/react-start, and @tanstack/router-core. The last one is required
because this package augments the SerializableExtensions interface that lives
there.
