native-data-fetching

Implement and debug Expo network requests, caching, authentication, and offline data fetching.

1|Updated Jul 4, 2026
One-click install
npx skills add https://github.com/trungenglish/SHOPWISE --skill native-data-fetching-trungenglish
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: native-data-fetching
Source: https://github.com/trungenglish/SHOPWISE/tree/main/.agents/skills/native-data-fetching
Command: npx skills add https://github.com/trungenglish/SHOPWISE --skill native-data-fetching-trungenglish

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 pitfalls: unhandled fetch errors, insecure token storage, missing retry logic, offline failures, and misconfigured environment variables. This Skill provides proven patterns for every stage of mobile and web data fetching so you avoid these common mistakes. ## Core Features & Use Cases - Fetch & Error Handling: Typed API errors, exponential backoff retries, and AbortController-based request cancellation. - State Management: React Query (TanStack Query) setup for caching, mutations, and query invalidation, with guidance on when SWR is sufficient. - Auth & Security: Token storage with expo-secure-store, authenticated fetch wrappers, and token refresh flows. - Offline & Configuration: NetInfo-based connectivity detection, React Query offline sync, and EXPO_PUBLIC_ environment variable configuration for dev/prod API URLs. - Expo Router Loaders: Route-level data loading with useLoaderData for web on SDK 55+, including SSR, static generation, and server-side secrets. - Use Case: You are building a shop app that must load product data on web and native, handle expired auth tokens, and keep working when the user loses connectivity—this Skill walks you through each piece. ## Quick Start Use the native-data-fetching skill to set up a React Query client with an authenticated fetch wrapper and offline support in my Expo app.

Frequently Asked Questions about native-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 for non-2xx statuses before parsing JSON. Wrap requests in a helper that handles network failures and supports retries with exponential backoff.

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

React Query (TanStack Query) suits complex apps needing caching, mutations, invalidation, and offline persistence. SWR or custom hooks are sufficient for simpler fetching needs with basic caching requirements.

How do I store authentication tokens securely in Expo?▼

Store tokens with expo-secure-store, never AsyncStorage, since SecureStore uses encrypted platform keychains. Combine it with an authenticated fetch wrapper that attaches the Bearer token and a refresh flow for expired tokens.

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

Use EXPO_PUBLIC_ prefixed variables in .env.development and .env.production files, accessed via process.env. These are inlined at build time, so restart the dev server after changes and never put secrets in EXPO_PUBLIC_ variables.

Do Expo Router loaders work on native platforms?▼

No, Expo Router loaders are web-only and require SDK 55+ with server or static web output. For native platforms, use client-side fetching with React Query or fetch instead.

Why does my app fail when the device goes offline?▼

Requests fail offline because fetch has no built-in connectivity handling. Use NetInfo to detect network status and connect it to React Query's onlineManager so queries pause when offline and resume when connectivity returns.