dev_tool/tool_logo/white/tanstack_query.svg

Tanstack Query Online playground

Learn how to configure Tanstack Query with various options using the Online Playground, offering hands-on practice and customization.

Parameters
Network Mode
TanStack Query provides three different network modes to distinguish how Queries and Mutations should behave if you have no network connection. This mode can be set for each Query / Mutation individually, or globally via the query / mutation defaults.
Document
    online
    Queries and Mutations will not fire unless you have network connection
    always
    TanStack Query will always fetch and ignore the online / offline state. This is likely the mode you want to choose if you use TanStack Query in an environment where you don't need an active network connection for your Queries to work
    offlineFirst
    TanStack Query will run the queryFn once, but then pause retries.
Stale Time
The time in milliseconds after data is considered stale.,If set to `Infinity`, the data will never be considered stale.
Retry
Enabled or disable retry (Default true).
    Yes
    No
Max Retry
Failed queries will retry until the failed query count meets that number
Refetch Interval
If set to a number, the query will continuously refetch at this frequency in milliseconds.
Refetch Interval In Background
If set to `true`, the query will continue to refetch while their tab/window is in the background. Defaults to `false`.
    Yes
    No
Refetch On Window Focus
Refetch on user refocus on windows. true`: the query will refetch on window focus if the data is stale. `false`: the query will not refetch on window focus. `always`: the query will always refetch on window focus.
    true
    true
    false
    false
    always
    always
Refetch On Reconnect
Refetch when network is coming back
    true
    true
    false
    false
    always
    always
Refetch On Mount
Refetch when component is mounted
    true
    true
    false
    false
    always
    always
Retry On Mount
If set to false, the query will not be retried on mount if it contains an error. Defaults to true.
    Yes
    No
Throw On Error
If the query errors, the error will only be logged. If you want an error to be thrown, pass the throwOnError: true option
    Yes
    No
Suspense
Set this to true to enable suspense mode
Document
    Yes
    No
index.ts
Sharing / Save
Copy the link to easily share it with friends, or save the result to revisit and use it later at your convenience.
Copy link
Save
dev_tool/tool_logo/black/tanstack_query.svg

Tanstack Query blogs

Knowledge / tutorial / howto about Tanstack Query