Expo Integration Guide

Use the runtime Fetch implementation in an Expo application and optionally connect Expo SecureStore to the client's token callbacks.


Installation in Expo

Run the standard expo install command:

bash
npm install react-native-fetch-client

Integration with Expo SecureStore

Store your authentication tokens securely in iOS Keychain / Android Keystore using expo-secure-store:

expo-api.ts
typescript
import { createClient } from 'react-native-fetch-client';
import * as SecureStore from 'expo-secure-store';

export const api = createClient({
  baseURL: 'https://api.myexpoapp.com',
  auth: {
    getToken: async () => {
      return await SecureStore.getItemAsync('user_jwt_token');
    },
    refreshToken: async () => {
      const refreshToken = await SecureStore.getItemAsync('user_refresh_token');
      const res = await fetch('https://api.myexpoapp.com/auth/refresh', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ refreshToken }),
      });
      const data = await res.json();
      await SecureStore.setItemAsync('user_jwt_token', data.accessToken);
      return data.accessToken;
    },
  },
});
Check runtime support
The package uses Fetch and does not add a native networking module. Confirm that the Expo runtime version you target provides the Fetch APIs required by the features you use. SecureStore is a separate Expo package with its own installation requirements.