Connect React Native

Install the SDK, configure your key, make your first authenticated call, and stream an agent

The @recursiv/sdk works in React Native and Expo with zero extra dependencies and no native modules. It uses the runtime’s native fetch. The one difference from web is agent streaming: React Native does not expose ReadableStream, so you use chatStreamText() instead of chatStream().

Install

$npx expo install @recursiv/sdk

Or with npm:

$npm install @recursiv/sdk

Configure the key

No account yet? Sign up and mint a key at recursiv.io/account/api-keys.

A mobile app ships its bundle to the device, so never hardcode a long-lived sk_live_ key. Sign the user in and store a short-lived, scoped key in the platform keychain via expo-secure-store. Never use AsyncStorage for secrets.

1import { Recursiv } from '@recursiv/sdk';
2import * as SecureStore from 'expo-secure-store';
3
4async function getClient(): Promise<Recursiv> {
5 const apiKey = await SecureStore.getItemAsync('recursiv_api_key');
6 if (!apiKey) throw new Error('Not authenticated');
7 return new Recursiv({ apiKey });
8}

First authenticated call

All non-streaming methods work normally. Project-scoped calls return a { data } envelope.

1const r = await getClient();
2
3const { data: result } = await r.databases.query({
4 project_id: projectId,
5 sql: 'SELECT NOW() as time',
6});
7
8console.log(result.rows);

Run and stream an agent

Do not use chatStream() in React Native. The native fetch does not support ReadableStream. Use chatStreamText(), which delivers text deltas without requiring a readable stream.

1import { useState } from 'react';
2import { Recursiv } from '@recursiv/sdk';
3
4export function useAgentChat(agentId: string, apiKey: string) {
5 const [text, setText] = useState('');
6
7 async function send(message: string) {
8 const r = new Recursiv({ apiKey });
9 setText('');
10 await r.agents.chatStreamText(agentId, { message }, (delta) => {
11 setText((prev) => prev + delta);
12 });
13 }
14
15 return { text, send };
16}

For a full SSE-based component and auth flow, see the React Native SDK guide.

Create the agent once (server side or in a script). The model field is model agnostic:

1const { data: agent } = await r.agents.create({
2 project_id: projectId,
3 name: 'Support Bot',
4 model: 'anthropic/claude-sonnet-4.6',
5 system_prompt: 'You are a helpful assistant.',
6});

Where to go next