CopilotKitProvider
The React Native provider that configures the CopilotKit runtime connection and shares it with all hooks and components.
Overview
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
import { CopilotKitProvider } from "@copilotkit/react-native";Props
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Usage
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>
);
}Behavior
- Auto-polyfills: importing the package installs the Web API polyfills CopilotKit relies on (
ReadableStream,TextEncoder,crypto.getRandomValues,DOMException,location) before any CopilotKit code runs. - Shared render-tool registry: the provider instantiates the CopilotKit client whose renderer registry is shared with the rest of CopilotKit. Render functions registered by
useRenderTool(oruseComponent) write into that registry, souseRenderToolanduseRenderToolCallwork anywhere below the provider — there is no separateRenderToolProviderwrapper. - Stable references: header functions and
propertiesare memoized internally to avoid effect churn on re-render.
Related
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