| title | CopilotKitProvider |
|---|---|
| description | The React Native provider that configures the CopilotKit runtime connection and shares it with all hooks and components. |
CopilotKitProvider is the React Native provider for CopilotKit. Wrap your app (or the sub-tree that needs a copilot) with it to configure the runtime connection. Every hook and component below it reads the configured client from context.
Importing the package auto-installs the polyfills CopilotKit needs on Hermes, so you do not have to import them manually before using the provider.
Cloud features (`publicLicenseKey` / license-gated functionality) are not yet supported on React Native. Point `runtimeUrl` at a self-hosted runtime.import { CopilotKitProvider } from "@copilotkit/react-native";<CopilotKitProvider
runtimeUrl="https://your-server/api/copilotkit"
onError={(event) => {
console.error(`[${event.code}]`, event.error.message, event.context);
}}
>
<App />
</CopilotKitProvider>import { CopilotKitProvider } from "@copilotkit/react-native";
import { SafeAreaProvider } from "react-native-safe-area-context";
import { ChatScreen } from "./ChatScreen";
export default function App() {
return (
<SafeAreaProvider>
<CopilotKitProvider runtimeUrl="https://your-server/api/copilotkit">
<ChatScreen />
</CopilotKitProvider>
</SafeAreaProvider>
);
}- Auto-polyfills: importing the package installs the Web API polyfills CopilotKit relies on (
ReadableStream,TextEncoder,crypto.getRandomValues,DOMException,location) before any CopilotKit code runs. - Render-tool registry: the provider wraps children in a
RenderToolProvider, souseRenderToolworks anywhere below it. - Stable references: header functions and
propertiesare memoized internally to avoid effect churn on re-render.
useCopilotKit: access the configured client from any descendantuseAgent: connect to an agent and read its state- Polyfills: what gets installed and how to bring your own