A bare React Native 0.85 app demonstrating @copilotkit/react-native with useAgent and useCopilotKit hooks.
Make sure you have completed the React Native environment setup before proceeding.
- Node.js >= 22.11
- pnpm (workspace root uses pnpm)
- Ruby + Bundler (for CocoaPods on iOS)
- Xcode (iOS) and/or Android Studio (Android)
From the repository root:
pnpm installThe demo uses workspace-linked @copilotkit/* packages, so they need to be built first:
pnpm nx run-many -t build --projects=@copilotkit/core,@copilotkit/shared,@copilotkit/react-core,@copilotkit/react-nativeFrom this directory (examples/v2/react-native/demo):
bundle install
cd ios && bundle exec pod install && cd ..pnpm startTo clear Metro's cache (recommended after rebasing or changing native deps):
pnpm start -- --reset-cacheIn a separate terminal:
pnpm run iosMake sure ANDROID_HOME is set. On macOS, add to your ~/.zshrc:
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator:$ANDROID_HOME/platform-toolsThen launch an emulator from Android Studio (or connect a physical device) and run:
pnpm run androidApp.tsx — CopilotKitProvider setup with runtime URL
src/ChatScreen.tsx — Chat UI using useAgent + useCopilotKit hooks
index.js — Entry point with polyfill imports
metro.config.js — pnpm monorepo compatibility config
The app connects to a hosted CopilotKit runtime by default. To use a local runtime, edit App.tsx:
// const RUNTIME_URL = "https://langgraph-py.examples.copilotkit.ai/api/copilotkit";
const RUNTIME_URL = "http://localhost:3000/api/copilotkit";- Metro can't resolve modules: Run
pnpm start -- --reset-cacheto clear the Metro cache. - CocoaPods errors: Re-run
cd ios && bundle exec pod install. - Android SDK not found: Make sure
ANDROID_HOMEis set (see Android section above). - No emulators found: Open Android Studio, go to Device Manager, and create/start an AVD.
- Build failures after pulling changes: Rebuild the CopilotKit packages (step 2 above).
- See the React Native Troubleshooting guide for general issues.