Skip to main content
Fetch and cache data with the createQuery primitive. It returns a reactive query result that automatically updates when dependencies change in SolidJS.

Signature

Parameters

Accessor<CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>>
required
A Solid accessor (function) returning query configuration options.
Accessor<QueryClient>
Accessor returning a custom QueryClient instance. If not provided, uses the client from context.

Returns

object
Reactive query state that updates automatically.

Type Parameters

  • TQueryFnData - Type returned by the query function
  • TError - Type of error (defaults to DefaultError)
  • TData - Type of data returned (defaults to TQueryFnData)
  • TQueryKey - Type of the query key (defaults to QueryKey)

Examples

Basic Usage

Reactive Query Keys

With TypeScript

Conditional Fetching

With Select

Dependent Queries

Initial Data

Polling/Refetch Interval

Manual Refetch

Error Handling

Notes

The options parameter must be an accessor (function). This allows SolidJS to track dependencies and automatically refetch when reactive values change.
Use createMemo if you need to derive query options from multiple signals: