Start here

Build with react-native-fetch-client

A Fetch-native HTTP client for React Native, Expo, browsers, and Node.js. Install it, create a client, and make a typed request in a few lines.

Installation

Install the package with your preferred package manager:

shell
npm install react-native-fetch-client

The package declares Node.js 18 or newer in its engine requirements.

Your first request

Create a client with your API base URL. Request methods resolve to a response object whose data property contains the parsed body.

typescript
import { createClient } from 'react-native-fetch-client';

type User = {
  id: number;
  name: string;
};

const api = createClient({
  baseURL: 'https://api.example.com',
  timeout: 8_000,
});

const response = await api.get<User>('/users/1');
console.log(response.data.name);

Use the same API from JavaScript. TypeScript types are optional at runtime.

javascript
import { createClient } from 'react-native-fetch-client';

const api = createClient({ baseURL: 'https://api.example.com' });

const response = await api.get('/users/1');
console.log(response.data);

Runtime compatibility

The package describes support for React Native, Expo, modern browsers, and Node.js. Requests use the runtime’s Fetch implementation by default. If your environment needs a different implementation, set fetchImpl in the client configuration.

React Native and Expo projects should use versions that provide the Fetch APIs required by their app. The package does not install platform-specific networking dependencies.

Guides

Choose a guide

Browse API reference

Need more detail?

Read the source README, changelog, or open an issue on GitHub.