Streaming LLM responses in React Native: how to build a chat UI that feels instant
Streaming LLM responses in React Native needs a streaming-capable fetch, a server that does not buffer, and a UI that survives dropped connections. The architecture, the polyfill traps and a decision table.
A user taps send in your AI chat screen and stares at a spinner for six seconds. The model is fine. The answer was generated in pieces the whole time, but nothing reached the screen until the last piece arrived. Streaming LLM responses in React Native fixes that perception problem, and it is where many mobile AI builds first stall, because the part that works on the web does not always work on the phone.
This post covers what has to be true at each layer for tokens to show up as they are generated, where the mobile-specific traps are, and how to decide how much of it to build yourself. For the model-side view of the same problem, see LLM latency and time to first token.
Why does streaming break on mobile when it works on the web?
Streaming is a chain, and it only works if every link passes data along incrementally:
The model provider streams tokens.
Your server relays them without buffering.
The network path (CDN, proxy) does not hold them back.
The client's fetch exposes the body as a stream.
The UI re-renders without choking on frequent updates.
On the web, link 4 is a given. In React Native it is the most common break. Expo's documentation describes expo/fetch as a WinterCG-compliant Fetch implementation, and shows streaming by calling getReader() on the response body and reading chunks in a loop until done. The same page notes that on Android and iOS it is installed as the global fetch, and that setting EXPO_PUBLIC_USE_RN_FETCH=1 keeps React Native's built-in fetch instead (Expo docs). So whether your app streams can depend on an environment flag and your SDK version, not on your server code.
What does a working React Native streaming setup need?
The Vercel AI SDK's Expo guide is a useful reference for the moving parts, even if you do not adopt the SDK (AI SDK Expo guide). According to that guide:
The chat hook (useChat) is given a transport that uses expo/fetch, because it supports streaming responses. This requires Expo 52 or higher.
The server route calls streamText and returns a UI message stream response, with headers that discourage buffering.
On native, structuredClone, TextEncoderStream and TextDecoderStream may be missing. The guide installs @ungap/structured-clone and @stardazed/streams-text-encoding as polyfills, loaded only when Platform.OS !== 'web', and tells you to add them if you see a "structuredClone doesn't exist" error.
Messages are made of ordered parts, and you render each part by type (text, or tool-<name> for tool calls).
That last point matters for design. Once your assistant calls tools, a message is no longer one string, so build the message list around parts from day one rather than retrofitting it.
Which approach should you use for a mobile chat feature?
Option
What it is
Good when
Watch out for
Hosted SDK chat hook on expo/fetch
Library manages message state and parsing
You want chat working fast on Expo
Polyfills, SDK version requirements, coupling to the library's message format
Hand-rolled stream reader
You call getReader() and parse chunks yourself
Custom protocol, or no extra dependency wanted
You own parsing, partial chunks and error cases
Non-streaming request with a loading state
One request, full answer
Short answers, structured output, background tasks
Long perceived wait on longer answers
Push or polling for finished results
Server finishes, client is notified
Long agent runs that outlive the screen
More infrastructure, no live typing effect
Streaming is not always the right answer. If the response is a short classification or a JSON object, a full response is simpler and there is nothing useful to show halfway. See structured output in production for why partial JSON is a poor thing to render.
How do you keep the API key and the bill off the device?
Do not call the model provider straight from the app. Anything bundled in a mobile app should be treated as readable by users, so the key belongs on your server, and the app authenticates to your endpoint instead. The same server is where you enforce limits per user; the patterns in AI usage limits per customer and rate limits and 429 handling apply unchanged, and a fallback provider is easier to add behind your own endpoint than inside a shipped binary.
Also note the AI SDK guide's development setup uses a development URL, while production needs an explicit API base URL environment variable. A build that works in the simulator and points at the wrong host in a release build is a classic last-week surprise.
What breaks on real phones?
These are design questions rather than library features. Test each on a physical device on a poor connection, not only on office Wi-Fi.
Connection dropped mid-answer. The client has partial text. Decide whether to show it with a retry control or to resume from a server-stored answer. Do not silently show a truncated answer as if it were complete.
App backgrounded. The OS may suspend the connection. On return, reconcile with what the server saved.
Re-render pressure. Updating state for every token can make long answers janky. Batch updates on a short interval and keep message rows memoised so only the last row re-renders.
Scrolling. Auto-scroll to the bottom only while the user has not scrolled up, or the screen fights them.
Cancel. Give the user a stop button that aborts the request, and make sure the server stops generating, since otherwise you keep paying for tokens nobody reads.
Buffering middleboxes. If it streams locally but arrives in one block in production, suspect a proxy or CDN setting before the app.
What to do next
Start by proving the chain end to end with the smallest possible test: a server route that emits a few chunks a second apart, and a screen that prints them as they arrive, on a release build on a real device. If chunks arrive together, you have found your buffering link. Only then add message state, tools and polish.
If you are deciding between running a model on the phone and calling one in the cloud, read on-device AI vs cloud AI for mobile apps first, since it changes what you need to stream at all. If you want a team to build the mobile chat experience and the backend behind it, that is what our AI mobile apps service covers.
CodeKrypt
Drafted by CodeKrypt's AI writing pipeline, built and maintained by our engineers, under fixed rules on sources and claims. How we write
Frequently asked questions
Why does streaming not work with fetch in my React Native app?
Historically React Native's built-in fetch did not expose the response body as a readable stream, so the whole answer arrived at once. Expo's documentation describes expo/fetch as a WinterCG-compliant fetch whose response body can be read with getReader() in a loop, and the Vercel AI SDK's Expo guide says to pass it to the chat transport because it supports streaming (Expo SDK 52 or higher). Check which fetch your app actually uses before debugging the server.
Should the mobile app call the LLM provider directly?
No. Keep the provider API key on your own server and have the app call your endpoint. A key shipped inside an app bundle can be extracted, and a server in the middle is also where you apply per-user limits, logging and fallbacks.
What happens if the user switches apps or loses signal mid-answer?
The stream is cut and the partial text is all the client has. Decide up front whether to show the partial answer with a retry button, or have the server persist the finished answer so the client can fetch it on return. Mobile networks drop connections routinely, so this needs a design, not an afterthought.
Voice AI agent latency is not just model speed. How turn detection, endpointing and barge-in handling decide whether callers feel heard, and how to measure each stage.
AI chatbot metrics that matter: why containment rate flatters a bot that is failing, how to define and sample resolution rate, and the dashboard a buyer should ask for.
A WhatsApp AI chatbot is priced per message, gated by a 24-hour window and limited by Meta's AI policy. Here is what that does to cost and architecture.