import { useQuery } from '@tanstack/solid-query' import { Suspense, createSignal } from 'solid-js' import { NoHydration } from 'solid-js/web' import { Title } from '@solidjs/meta' import type { UseQueryResult } from '@tanstack/solid-query' import { fetchUser } from '~/utils/api' export default function Hydration() { const query = useQuery(() => ({ queryKey: ['user'], queryFn: () => fetchUser({ sleep: 500 }), deferStream: true, })) const [initialQueryState] = createSignal(JSON.parse(JSON.stringify(query))) return (
Solid Query - Hydration

Solid Query - Hydration Example

Lists the query state as seen on the server, initial render on the client (right after hydration), and current client value. Ideally, if SSR is setup correctly, these values are exactly the same in all three contexts.

Context data.name isFetching isFetched isPending isRefetching isLoading isStale isSuccess isError error fetchStatus dataUpdatedAt
) } type QueryState = UseQueryResult< { id: string name: string queryTime: number }, Error > const QueryStateRow = (props: { context: string; query: QueryState }) => { return ( {props.context} {props.query.data?.name} {String(props.query.isFetching)} {String(props.query.isFetched)} {String(props.query.isPending)} {String(props.query.isRefetching)} {String(props.query.isLoading)} {String(props.query.isStale)} {String(props.query.isSuccess)} {String(props.query.isError)} {String(props.query.error)} {String(props.query.fetchStatus)} {String(props.query.dataUpdatedAt)} ) }