Solid Query Overview
TanStack Solid Query is a powerful library for managing server state in SolidJS applications. It provides primitives for fetching, caching, synchronizing, and updating asynchronous data with zero-config, automatic caching, background updates, and more.What is Solid Query?
Solid Query is the SolidJS adapter for TanStack Query, bringing all the power of TanStack Query to SolidJS applications with full support for SolidJS reactivity primitives and patterns.Solid Query leverages SolidJS’s fine-grained reactivity system and Resources to provide optimal performance and developer experience.
Key Features
- Transport/Protocol Agnostic: Works with REST, GraphQL, or any promise-based data fetching
- Auto Caching + Refetching: Implements stale-while-revalidate with window refocus and polling support
- Parallel + Dependent Queries: Execute multiple queries efficiently
- Mutations + Reactive Query Refetching: Update data with automatic cache invalidation
- Multi-layer Cache: Built-in automatic garbage collection
- Pagination + Infinite Scroll: First-class support with scroll recovery
- Request Cancellation: Automatic cleanup of outdated requests
- SSR Support: Full server-side rendering with streaming
- Dedicated Devtools: Visual debugging and inspection tools
Core Concepts
Queries
Queries are declarative dependencies on asynchronous data sources. Use theuseQuery primitive to fetch data:
Mutations
Mutations are used to create, update, or delete data. Use theuseMutation primitive:
Infinite Queries
For paginated or infinite scroll data, useuseInfiniteQuery:
SolidJS Integration
Reactive Primitives
Solid Query is built on SolidJS primitives:- Uses
createResourceinternally for suspense support - Integrates with
createStorefor reactive state - Leverages
createComputedandcreateMemofor efficient updates - Supports
onCleanupfor proper resource disposal
Suspense Support
The
data property on query results is a SolidJS Resource that automatically suspends when loading.Query Client Provider
All queries and mutations must be wrapped in aQueryClientProvider:
Server-Side Rendering
Solid Query has first-class support for SSR:Query Options Helper
UsequeryOptions for type-safe, reusable query configurations:
Performance Considerations
Fine-Grained Reactivity
Solid Query integrates with SolidJS’s fine-grained reactivity:Reconciliation
Solid Query uses SolidJS’sreconcile for efficient updates:
Error Handling
Handle errors with SolidJS’sErrorBoundary:
Next Steps
Installation
Install and configure Solid Query in your project
Quick Start
Build your first Solid Query application
TypeScript
Learn about TypeScript support and type safety
DevTools
Debug and visualize your queries with DevTools