expo-data-fetching

Implement and debug network requests, caching, and offline support in Expo apps.

Updated Jul 28, 2026
One-click install
npx skills add https://github.com/truongnat/Restly --skill expo-data-fetching-truongnat
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: expo-data-fetching
Source: https://github.com/truongnat/Restly/tree/main/.agents/skills/expo-data-fetching
Command: npx skills add https://github.com/truongnat/Restly --skill expo-data-fetching-truongnat

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @tanstack/react-query, expo-secure-store, @react-native-community/netinfo, expo-router, expo-server, and includes references (resource) components.

What problem does it solve? Building reliable networking in Expo and React Native apps involves many moving parts: fetch error handling, token storage, retries, caching, offline behavior, and environment-based API configuration. This Skill provides proven patterns and code for each of these concerns so you avoid common mistakes like insecure token storage or missing HTTP status checks. ## Core Features & Use Cases - Fetch and Error Handling: Typed ApiError classes, HTTP status checks, exponential backoff retries, and AbortController cancellation. - React Query Integration: QueryClient setup, queries, mutations with cache invalidation, and offline-first syncing with NetInfo via onlineManager. - Authentication: Token storage with expo-secure-store, authenticated fetch wrappers, and token refresh flows. - Expo Router Data Loaders: Route-level loaders with useLoaderData, LoaderFunction typing, StatusError, and server vs static rendering guidance (web, SDK 55+). - Use Case: You need an API client that works across dev and production. Use the EXPO_PUBLIC_ environment variable patterns to configure base URLs per environment, then wrap fetch with auth headers and retry logic. ## Quick Start Use the expo-data-fetching skill to set up a React Query powered API client with error handling and secure token storage for my Expo app.

Frequently Asked Questions about expo-data-fetching

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I make API calls in React Native with fetch?▼

Use the fetch API with explicit response status checks: call fetch, verify response.ok, and throw a typed error with the status code before parsing JSON. For POST requests, set the Content-Type header to application/json and stringify the body.

Should I use React Query or SWR for data fetching?▼

React Query suits complex apps needing mutations, cache invalidation, and offline persistence, while SWR fits simpler fetching needs. React Query also handles request deduplication and automatic cancellation on unmount.

How do I store authentication tokens securely in Expo?▼

Store tokens with expo-secure-store using SecureStore.setItemAsync, never in AsyncStorage which is not encrypted. Wrap fetch in an authenticated helper that reads the token and attaches it as a Bearer Authorization header.

Does Expo Router support server-side data loaders?▼

Yes, Expo SDK 55+ supports route-level loaders on web via the unstable_useServerDataLoaders plugin option. Export an async loader from a route file and consume its data with useLoaderData; loaders are web-only and unavailable in _layout files.

How do I configure different API URLs for development and production in Expo?▼

Define EXPO_PUBLIC_API_URL in .env.development and .env.production files, then read process.env.EXPO_PUBLIC_API_URL in code. Variables are inlined at build time, so restart the dev server after changes and never put secrets in EXPO_PUBLIC_ variables.

How do I make my React Native app work offline?▼

Detect connectivity with @react-native-community/netinfo and sync it to React Query via onlineManager.setEventListener so queries pause offline and resume when back online. Combine with React Query persistence to cache data across sessions.