Skip to content
pubscout

tanstack_query

2.0.0, released 3 weeks ago by flutter-tanstack.com

Flutter implementation of TanStack Query for caching, synchronizing, and updating server state.

WASM-ready
$ flutter pub add tanstack_query
Source repository

What it does

Provides asynchronous state management, caching, refetching, and pagination patterns modeled after TanStack React Query v5. Uses Flutter hooks like useQuery, useInfiniteQuery, and useMutation to interact with a centralized QueryClient.

AI-written summary of version 2.0.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You want to manage, cache, and synchronize server-side or remote asynchronous data in Flutter.
  • You prefer the TanStack/React Query API design and patterns.
  • Your project heavily uses flutter_hooks for component logic.

Skip it when

  • You are managing complex local UI or app state rather than asynchronous server state.
  • Your codebase does not use and does not want to adopt flutter_hooks.

Strengths

  • Protocol-agnostic fetching supporting REST, GraphQL, and custom promises.
  • Built-in caching, background updates, deduplication, and automatic query invalidation.
  • Familiar API for developers coming from TanStack React Query.

Weaknesses

  • Requires flutter_hooks to use the primary hook-based API.
  • Maintained by independent developers as a copycat of the JavaScript library rather than an official port.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
4

Instantiate a QueryClient and wrap your application in a QueryClientProvider.

void main() {
  var queryClient = QueryClient();
  runApp(
    QueryClientProvider(client: queryClient, child: const App()),
  );
}

Alternatives

Packages that do the same job and could replace tanstack_query.

  • riverpod

    Offers robust built-in caching and asynchronous provider loading natively without depending on flutter_hooks.

  • flutter_riverpod

    Provides a comprehensive state management and dependency injection solution with excellent async data support.

  • bloc

    A predictable state management library using events and states for explicit and testable data flow.

Works with

Packages commonly used together with tanstack_query: ones it builds on, ones built on it, and its own family.