@monarcode/effetch-query/react/tanstack-router
Every export of the TanStack Router entry point: connecting a client to a router, and so to TanStack Start.
@monarcode/effetch-query/react/tanstack-router connects a query client to a TanStack Router, and so to TanStack Start. Import what you use:
import { } from "@monarcode/effetch-query/react/tanstack-router";Its exports follow, grouped by the guide that covers them. Each one has the first paragraph of its docs, and what it needs and how it fails; your editor shows the rest, with an example, when you hover the name.
TanStack Router and Start
Guide: TanStack Router and Start.
connectQueryClient
Connects a query client to a TanStack Router (and so TanStack Start), as TanStack's setupRouterSsrQueryIntegration does for TanStack Query. Call it where the router is made: Start's getRouter, or your server and browser entries.
- On the server, the queries your loaders loaded go with the page, and queries started while rendering follow as they start, those still loading as promises the browser waits for, so nothing is fetched twice. The client is disposed when the request ends: make one per request from a process-wide
ManagedRuntime(QueryClient.make({ runtime })), so your app's layer is built once rather than per request (see the example). - In the browser, they load into the client before React hydrates, with no
HydrationBoundary. - Redirects: a query or mutation that fails or dies with a router
redirect()navigates there, in the browser. Write it asEffect.die(redirect({ to: "/login" })), to keep it out of the error type, inside the Effect so each run makes its own: the router resolves a redirect in place. A fetch an Effect awaits (Query.fetchorQuery.prefetch) is left to it: in a loader,client.fetchrejects with the redirect and the router follows it, and a preload's is dropped, as the router drops it. So load a query that may redirect withclient.fetch: one only prefetched fails in its readers instead.
ConnectDehydrateOptions
Which queries connectQueryClient sends from the server, as QueryClient.DehydrateOptions chooses them. Queries still loading are always sent, as promises the browser waits for: the router's serializer carries them.
Prop
Type
ConnectQueryClientOptions
Options for connectQueryClient.
Prop
Type
Related pages
- Entry points: what each entry point exports.
@monarcode/effetch-query: the core entry point's namespaces and top-level names.Query: defining queries, keys and targets, and the cache from Effect.InfiniteQuery: queries that load a list one page at a time.Mutation: defining and running mutations.Entity: records whose every cached copy a write updates.QueryClient: the client, its options and hooks, and server rendering.Signals: where a client hears about focus and reconnects.@monarcode/effetch-query/react: the provider, the hooks and the boundaries.@monarcode/effetch-query/effetch: queries and mutations from Effetch endpoints.@monarcode/effetch-query/react-native: focus and online signals for React Native.