Skip to main content

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 the useQuery primitive to fetch data:

Mutations

Mutations are used to create, update, or delete data. Use the useMutation primitive:

Infinite Queries

For paginated or infinite scroll data, use useInfiniteQuery:

SolidJS Integration

Reactive Primitives

Solid Query is built on SolidJS primitives:
  • Uses createResource internally for suspense support
  • Integrates with createStore for reactive state
  • Leverages createComputed and createMemo for efficient updates
  • Supports onCleanup for 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 a QueryClientProvider:

Server-Side Rendering

Solid Query has first-class support for SSR:
Queries automatically configure themselves for server-side rendering. Retry is disabled and errors are thrown to be caught by ErrorBoundary.

Query Options Helper

Use queryOptions 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’s reconcile for efficient updates:

Error Handling

Handle errors with SolidJS’s ErrorBoundary:

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