Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

overview.md

52 lines1.5 KB

1---
2id: overview
3title: Overview
4---
5​
6`@tanstack/octane-query` is the official Octane adapter for TanStack Query. It
7uses `@tanstack/query-core` unchanged and binds Query observers to Octane's
8hooks, context, Suspense, and component lifecycle.
9​
10Most binding-level code can move from React Query by changing the import. The
11adapter includes queries, infinite queries, parallel queries, mutations,
12prefetch hooks, cache status hooks, Suspense hooks, error reset boundaries,
13restoration state, and hydration. It also re-exports every Query Core API.
14​
15```tsrx
16import {
17 QueryClient,
18 QueryClientProvider,
19 useQuery,
20} from '@tanstack/octane-query'
21​
22const queryClient = new QueryClient()
23​
24function Todos() @{
25 const query = useQuery({
26 queryKey: ['todos'],
27 queryFn: fetchTodos,
28 })
29​
30 @if (query.isPending) {
31 <span>{'Loading'}</span>
32 } @else if (query.isError) {
33 <span>{query.error.message}</span>
34 } @else {
35 <ul>{query.data as unknown}</ul>
36 }
38​
39function App() @{
40 <QueryClientProvider client={queryClient}>
41 <Todos />
42 </QueryClientProvider>
44```
45​
46Octane hooks receive compiler-injected call-site slots. The adapter derives
47stable sub-slots for the Query observer, subscription, and effects, so call the
48hooks normally and let the Octane compiler transform them.
49​
50Start with [Installation](./installation.md), then [Quick Start](./quick-start.md).
51See [Suspense and Error Boundaries](./guides/suspense.md) and [Server Rendering
52and Hydration](./guides/ssr.md) for the framework-specific behavior.