showcase/shell-docs/src/content/reference/react-native/components/CopilotKitProvider.mdx
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.
<Callout type="info"> Cloud features (`publicLicenseKey` / license-gated functionality) are not yet supported on React Native. Point `runtimeUrl` at a self-hosted runtime. </Callout>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>
);
}
ReadableStream, TextEncoder, crypto.getRandomValues, DOMException, location) before any CopilotKit code runs.RenderToolProvider, so useRenderTool works anywhere below it.properties are 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