React Native Adapter
This guide explains how to use oRPC with React Native, including the platform’s supported features and current limitations.
Fetch Link
React Native provides a built-in Fetch API, allowing you to connect to an oRPC server over HTTP. Learn more in the Fetch Client Adapter documentation.
import { RPCLink } from '@orpc/client/fetch'
const link = new RPCLink({
origin: 'https://api.example.com',
url: '/rpc',
headers: async ({ context }) => ({
'x-api-key': context?.something ?? ''
})
})
Limitations
The built-in fetch implementation in React Native does not support
File/Blob/ReadableStream<Uint8Array> or
AsyncIteratorObject. Follow
Support Stream #27741
for progress.
If you’re using Expo SDK 56 or later, with expo/fetch, you can:
- Upload File/Blob when they are the entire input.
- Receive
ReadableStream<Uint8Array>and AsyncIteratorObject when they are the entire output.
WebSocket Link
React Native also provides built-in WebSocket support, allowing you to connect to an oRPC server over WebSocket. Learn more in the WebSocket Client Adapter documentation.
import { RPCLink } from '@orpc/client/websocket'
const link = new RPCLink({
connect: () => new WebSocket('ws://localhost:3000'),
})