npx skills add ...
npx skills add expo/skills --skill native-data-fetching
Use when implementing or debugging ANY network request, API call, or data fetching. Covers fetch API, React Query, SWR, error handling, caching, offline support, and Expo Router data loaders (`useLoaderData`).
npx skills add expo/skills --skill native-data-fetching
You MUST use this skill for ANY networking work including API requests, data fetching, caching, or network debugging.
Consult these resources as needed:
Use this skill when:
useLoaderData, web SDK 55+)Simple GET request:
POST request with body:
Setup:
Fetching data:
Mutations:
Comprehensive error handling:
Retry logic:
Token management:
Token refresh:
Check network status:
Offline-first with React Query:
Using environment variables for API configuration:
Expo supports environment variables with the EXPO_PUBLIC_ prefix. These are inlined at build time and available in your JavaScript code.
Environment-specific configuration:
Creating an API client with environment config:
Important notes:
EXPO_PUBLIC_ are exposed to the client bundleEXPO_PUBLIC_ variables—they're visible in the built app.env filesEXPO_PUBLIC_ prefixTypeScript support:
Cancel on unmount:
With React Query (automatic):
Wrong: No error handling
Right: Check response status
Wrong: Storing tokens in AsyncStorage
Right: Use SecureStore for sensitive data
User: "How do I make API calls in React Native?" -> Use fetch, wrap with error handling
User: "Should I use React Query or SWR?" -> React Query for complex apps, SWR for simpler needs
User: "My app needs to work offline" -> Use NetInfo for status, React Query persistence for caching
User: "How do I handle authentication tokens?" -> Store in expo-secure-store, implement refresh flow
User: "API calls are slow" -> Check caching strategy, use React Query staleTime User: "How do I configure different API URLs for dev and prod?" -> Use EXPOPUBLIC env vars with .env.development and .env.production files User: "Where should I put my API key?" -> Client-safe keys: EXPOPUBLIC in .env. Secret keys: non-prefixed env vars in API routes only
User: "How do I load data for a page in Expo Router?" -> See references/expo-router-loaders.md for route-level loaders (web, SDK 55+). For native, use React Query or fetch.