Skip to main content

Quick Start Guide

Get up and running with Solid Query in just a few minutes. This guide will walk you through creating a simple application that fetches and displays data.

Complete Example

Here’s a complete working example to get you started:

Step-by-Step Guide

Let’s break down the key concepts:

Query Keys

Query keys are how Solid Query identifies and caches your data. They can be simple strings or arrays:
Query keys must be serializable and should include all variables that affect the query function.

Working with Suspense

Solid Query integrates seamlessly with SolidJS Suspense:
The data property is a SolidJS Resource that automatically suspends when the query is loading.

Dependent Queries

Sometimes you need to fetch data that depends on other data:

Pagination Example

Handle paginated data with ease:

Infinite Queries

For infinite scroll or “load more” functionality:

Optimistic Updates

Update the UI immediately while the mutation is in progress:

Best Practices

Follow these best practices for optimal performance and maintainability:
  1. Use Query Keys Consistently: Keep your query keys organized and consistent across your application
  2. Set Appropriate Stale Time: Configure staleTime based on how often your data changes
  3. Handle All States: Always handle loading, error, and success states
  4. Use Query Options Helper: Create reusable query configurations with queryOptions
  5. Leverage Suspense: Use Suspense boundaries for better loading experiences
  6. Invalidate Wisely: Invalidate queries after mutations to keep data fresh

Next Steps

TypeScript

Learn about TypeScript integration and type safety

DevTools

Debug your queries with Solid Query DevTools