File: suspense.md | Updated: 11/15/2025
Search...
+ K
Auto
Docs Examples GitHub Contributors
Docs Examples GitHub Contributors
Docs Examples GitHub Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Maintainers Partners Support Learn StatsBETA Discord Merch Blog GitHub Ethos Brand Guide
Documentation
Framework
Solid
Version
v5
Search...
+ K
Menu
Getting Started
Guides & Concepts
API Reference
ESLint
Examples
Plugins
Framework
Solid
Version
v5
Menu
Getting Started
Guides & Concepts
API Reference
ESLint
Examples
Plugins
On this page
Copy Markdown
Solid Query can also be used with Solid's Suspense API's.
To do that you need to wrap your suspendable component with Suspense component provided by Solid
tsx
import { Suspense } from 'solid-js'
;<Suspense fallback={<LoadingSpinner />}>
<SuspendableComponent />
</Suspense>
import { Suspense } from 'solid-js'
;<Suspense fallback={<LoadingSpinner />}>
<SuspendableComponent />
</Suspense>
You can use async suspense function that is provided by solid-query.
tsx
import { useQuery } from '@tanstack/solid-query'
const todoFetcher = async () =>
await fetch('https://jsonplaceholder.cypress.io/todos').then((response) =>
response.json(),
)
function SuspendableComponent() {
const query = useQuery(() => ({
queryKey: ['todos'],
queryFn: todoFetcher,
}))
// Accessing query.data directly inside a <Suspense> boundary
// automatically triggers suspension until data is ready
return <div>Data: {JSON.stringify(query.data)}</div>
}
import { useQuery } from '@tanstack/solid-query'
const todoFetcher = async () =>
await fetch('https://jsonplaceholder.cypress.io/todos').then((response) =>
response.json(),
)
function SuspendableComponent() {
const query = useQuery(() => ({
queryKey: ['todos'],
queryFn: todoFetcher,
}))
// Accessing query.data directly inside a <Suspense> boundary
// automatically triggers suspension until data is ready
return <div>Data: {JSON.stringify(query.data)}</div>
}
Fetch-on-render vs Render-as-you-fetch
--------------------------------------
Out of the box, Solid Query in suspense mode works really well as a Fetch-on-render solution with no additional configuration. This means that when your components attempt to mount, they will trigger query fetching and suspend, but only once you have imported them and mounted them. If you want to take it to the next level and implement a Render-as-you-fetch model, we recommend implementing Prefetching on routing callbacks and/or user interactions events to start loading queries before they are mounted and hopefully even before you start importing or mounting their parent components.
[###### Want to Skip the Docs?
Query.gg - The Official React Query Course
\
“If you’re serious about *really* understanding React Query, there’s no better way than with query.gg”—Tanner Linsley
Learn More](https://query.gg/?s=tanstack)
