Skip to main content
TanStack Query for Solid provides primitives for fetching, caching, and updating asynchronous data in your SolidJS applications. It leverages Solid’s fine-grained reactivity system.

Installation

Setup

Wrap your application with QueryClientProvider:

Core Primitives

useQuery (formerly createQuery)

Fetch and cache data with the useQuery primitive:
The hook was renamed from createQuery to useQuery in v5. Both names are exported for backward compatibility, but useQuery is now preferred.

Reactive Query Keys

Solid Query works seamlessly with Solid’s reactive primitives:
Pass a function to useQuery that returns the options object. This allows Solid’s reactivity to automatically track dependencies and re-run the query when signals change.

useMutation (formerly createMutation)

Perform side effects with mutations:

useInfiniteQuery (formerly createInfiniteQuery)

Implement infinite scrolling:

Solid’s Reactivity System

Fine-Grained Reactivity

Solid Query leverages Solid’s fine-grained reactivity for optimal performance:

Reconciliation

Solid Query includes a reconcile option for efficient data updates:
The reconcile option is Solid-specific and replaces React Query’s structuralSharing. It provides better performance for Solid’s reactivity system.

Advanced Patterns

useQueries (formerly createQueries)

Execute multiple queries in parallel:

Query Options Factory

useIsFetching

Show a global loading indicator:

useMutationState

Track all mutations:

TypeScript

Full TypeScript support with type inference:

SSR Support

Solid Query works with SolidStart for server-side rendering:

Migration from v4

The primitive names have changed in v5:
Both naming conventions are exported for backward compatibility, but the use* prefix is now preferred to align with other frameworks.

Solid-Specific Features

No Structural Sharing

Unlike React Query, Solid Query disables structural sharing by default because Solid’s reactivity system handles this more efficiently:

Function-Based Options

Always wrap options in a function () => ({ ... }) to enable reactivity. This is the key difference from React Query’s API.

Performance Tips

Avoid Unnecessary Destructuring

Use Show and For Components