Data · Fetching data from your API

Expo + TanStack Query

TanStack Query in an Expo SDK 57 app for iOS and Android, wired by one command and checked by doctor.

TanStack Query is the default data layer: a cache, retries and refetch-on-foreground for REST-shaped APIs, wired up in src/lib/query.tsx. I'd pick it over swr when you want mutations, query invalidation and devtool-grade cache control, and over apollo whenever your backend isn't GraphQL. It comes with src/lib/api/client.ts - a small fetchJson wrapper that resolves relative paths against EXPO_PUBLIC_API_URL - so your hooks stay free of URL plumbing.

When to pick TanStack Query

TanStack Query: The default. Reach for it when you want mutations, invalidation and real cache control over a REST API.

At a glance

Runs in Expo Go
Yes
Files added
7
npm packages
1
Keys to paste
EXPO_PUBLIC_API_URL
Included in
Free, Starter and Pro
Tests included
1

Set it up

bun run setup --data react-query

Setup copies the module in, installs SDK-matched versions and removes the options you did not pick. Then bun run doctor lists every key still missing, with a link to where you get it. The step-by-step guide is in the TanStack Query docs.

Wiring it by hand instead? Read the guide: TanStack Query in Expo: offline and refetch.

TanStack Query vs other data options

OptionExpo Gonpm packagesKeys to pasteIncluded in
TanStack QueryYes11Free, Starter and Pro
Apollo ClientYes31Starter and Pro
SWRYes11Starter and Pro

Questions

Can I use TanStack Query in Expo Go?

Yes. This module runs in Expo Go, so you can try it before you make a development build.

What do I need to set up TanStack Query in an Expo app?

Run bun run setup --data react-query, then paste one key into .env: EXPO_PUBLIC_API_URL. bun run doctor lists any that are missing, with a link to where you get each one.

Does the ReadyNative free tier include TanStack Query?

Yes. It is the data option in the free tier, which is MIT-licensed on GitHub. Starter and Pro add the stack picker, EAS store builds and doctor.

Can I build the app without TanStack Query?

Yes. Pick none for data (bun run setup --data none) - plain fetch; add TanStack Query/Apollo/SWR later.

TanStack Query or Apollo Client for Expo?

TanStack Query: The default. Reach for it when you want mutations, invalidation and real cache control over a REST API. Apollo Client: Pick it when your backend speaks GraphQL.

TanStack Query or SWR for Expo?

TanStack Query: The default. Reach for it when you want mutations, invalidation and real cache control over a REST API. SWR: The same job with a much smaller surface: a string key is a request. Good when you mostly read.

Which TanStack Query version does it install?

For Expo SDK 57: @tanstack/react-query ^5.103.2. Setup installs Expo packages with expo install, so they match the SDK.

Get it

TanStack Query is part of the free tier: clone it on GitHub. Starter and Pro add the stack picker, EAS store builds and doctor.