Claude API React Native Mobile Integration Guide
Integrating the Claude API into a React Native app is straightforward technically, but the real question most developers are actually asking is: where does the API key live, and how do I stream responses on a mobile client that doesn't fully support ReadableStream? The short answer is that you never call api.anthropic.com directly from the app bundle — you proxy through a backend, and you handle streaming with either Server-Sent Events over a dedicated library or a buffered-chunk fallback.
This guide walks through the architecture that actually works in production: authentication, request/response handling, streaming on iOS and Android, tool use, and tracking usage per user when you have thousands of app installs hitting the same underlying Claude account.
Why you can't call Claude directly from the app
Anthropic API keys are long-lived secrets. If you embed one in a React Native bundle — even obfuscated, even in native code — it can be extracted with basic reverse-engineering tools. Once it leaks, anyone can run unlimited requests on your account until you rotate the key, and you have no way to tell which traffic came from your app versus an attacker.
This means every mobile integration needs a server between the app and Claude. That server can be:
- Your own backend (Node, Python, Go, whatever you already run)
- A serverless function (Lambda, Cloudflare Worker, Vercel function)
- A hosted relay that handles auth, rate limiting, and usage metadata for you
If you don't want to build and maintain that relay layer yourself, SubToAPI gives you a scoped sub_live_... key, request logging, and per-key usage data out of the box — you still keep that key server-side, but you skip building the proxy infrastructure, rate limiting, and billing attribution from scratch.
Recommended architecture
React Native app
└── your backend (holds the API key, authenticates the user)
└── SubToAPI or Anthropic (holds the actual model credential)
The app authenticates to your backend with whatever user session system you already have (Firebase, Supabase, your own JWT). Your backend then calls the Claude endpoint with a server-held key and relays the response back. This gives you a natural point to:
- Rate-limit by user ID, not just by IP
- Log which feature or screen triggered which request
- Swap models or providers without touching the app
Basic request from your backend
A minimal non-streaming call from your server to SubToAPI looks like this:
const response = await fetch('https://api.subtoapi.app/v1/messages', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.SUBTOAPI_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'claude-sonnet-4',
max_tokens: 1024,
messages: [{ role: 'user', content: userMessage }],
}),
});
const data = await response.json();
Your React Native client then just calls your own /chat route:
const res = await fetch('https://your-backend.com/chat', {
method: 'POST',
headers: {
Authorization: `Bearer ${userSessionToken}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ message: userInput }),
});
const { reply } = await res.json();
Full request and response shapes are documented at /docs/messages. If you're new to the API in general, /docs/quickstart covers the full request lifecycle.
Handling streaming on React Native
Streaming matters for mobile UX — users expect text to appear token by token, not a multi-second blank screen followed by a wall of text. The complication is that React Native's fetch implementation (via Hermes) doesn't reliably expose a readable stream body the way browser fetch does, and support varies by RN version and whether you're on the old or new architecture.
Two practical approaches:
1. SSE via a dedicated client library. Have your backend expose an SSE endpoint that relays Claude's stream, and consume it in the app with a library built for React Native SSE support (there are several maintained ones on npm — pick one actively updated for your RN version). This is the closest you'll get to web-style streaming.
2. Chunked polling fallback. Your backend buffers the stream and pushes partial text over a WebSocket or short-interval polling endpoint. More moving parts, but it sidesteps RN's fetch streaming quirks entirely and works consistently on both iOS and Android, including older devices.
The underlying streaming protocol and event format from the model side are documented at /docs/streaming — useful whether you're relaying raw or building your own chunking layer.
Tool use from a mobile client
If your app needs Claude to call functions — looking up account data, hitting a search index, triggering an action in your app — tool use works the same way as any backend integration. Define your tool schemas on the server, send them with each request, and execute the returned tool calls server-side before sending results back to Claude. Keep tool execution on the backend, not in the app, since tools often touch databases or internal services the app shouldn't have direct access to.
JSON schema details and examples are at /docs/tools.
Tracking usage per user
Once you have more than a handful of users, you'll want to know who's driving your Claude spend. Attribute each request to a user ID in your own backend logs, and if you're on SubToAPI, pair that with the usage metadata returned per request so you can reconcile cost per user without building a separate metering system. This becomes especially relevant if you're charging for AI features inside the app and need to know your margin per subscriber.
Getting started
- Stand up a thin backend route that accepts a user message and forwards it to Claude
- Get a key from /signup if you're using SubToAPI as the relay
- Wire your React Native app to call your backend, not the model API directly
- Add streaming once the basic request/response loop works
- Check /pricing to pick a plan that matches your expected request volume as usage grows
questions
Can I call the Claude API directly from a React Native app without a backend? Technically yes, but you'd have to embed a long-lived API key in the app bundle, which can be extracted and abused. Always proxy through a server you control.
Does streaming work the same on React Native as it does in a web browser? Not out of the box. Browser fetch exposes a readable stream; React Native's implementation is inconsistent across versions, so most teams use SSE libraries built for RN or a WebSocket/polling fallback relayed from their backend.
What's the simplest way to add Claude to an existing React Native app this week? Add a single backend route that forwards chat requests to /docs/quickstart-style calls, get a key via /signup, and start with non-streaming responses before adding streaming once the core flow works.