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.

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

First authenticated call

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

const r = await getClient();
const { data: result } = await r.databases.query({
project_id: projectId,
sql: 'SELECT NOW() as time',
});
console.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.

import { useState } from 'react';
import { Recursiv } from '@recursiv/sdk';
export function useAgentChat(agentId: string, apiKey: string) {
const [text, setText] = useState('');
async function send(message: string) {
const r = new Recursiv({ apiKey });
setText('');
await r.agents.chatStreamText(agentId, { message }, (delta) => {
setText((prev) => prev + delta);
});
}
return { text, send };
}

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:

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

Where to go next