Files
Tyler Slaton 7df369f955 fix(build): generalize per-mode resolution to all conditions; fail-loud helper
CR-loop confirmation-round #4 findings:

- validator: `resolvesForMode` (renamed from `typesCoversMode`) now applies to
  EVERY condition, not just `types`. A partial object under `node`/`default`
  (active in both modes) no longer silently covers the mode it lacks —
  resolution falls through to the sibling, catching the untyped-JS #3324 shape
  there. This completes the per-mode model.
- helper: `withTypesConditions` throws on a non-object `exports` (bare string /
  array) instead of iterating it into a corrupt map; `typedTarget` now warns
  loudly when a JS target has no adjacent declaration (was silent, contradicting
  the helper's own fail-loud contract); idempotency skips only the helper's own
  `{ types: <string>, ... }` output, so a hand-authored types-first PARTIAL
  object is normalized (its untyped sibling gets a `types`). UMD / `.d.mts` docs
  corrected; `ctx.pkg: unknown` documented as intentional (weak-type constraint).
- tests: node/default partial fall-through regression; types-first-partial
  normalization; a helper->validator round-trip; a console.warn assertion for
  the missing-declaration path; split the untouched-target test into silent
  (non-JS) and warning (JS) cases.
- react-native: dropped a pre-existing duplicate `@ag-ui/client` external.

Call sites: resolvesForMode (internal, walk + recursion; grep-confirmed no
`typesCoversMode` refs); withTypesConditions signature unchanged, and the new
throw/warn never fire on tsdown's real input (object map, packageJsonPath
present, dts:true).

36 tests pass; validator typechecks; validate:exports exits 0; native-loader
builds of react-core + react-native unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 20:40:27 -07:00
..
2026-06-23 20:50:16 -07:00

@copilotkit/react-native

Headless React Native bindings for CopilotKit. Provides a lightweight provider and re-exports platform-agnostic hooks -- no DOM, CSS, or web framework dependencies. You build the chat UI with standard React Native components.

Installation

npm install @copilotkit/react-native

Polyfills

React Native's JS runtime (Hermes) lacks several Web APIs that CopilotKit depends on. Import the polyfills before any other code in your entry point:

// index.js
import "@copilotkit/react-native/polyfills";

import { AppRegistry } from "react-native";
import App from "./App";
import { name as appName } from "./app.json";

AppRegistry.registerComponent(appName, () => App);

If you already polyfill some of these APIs, you can import only what you need:

import "@copilotkit/react-native/polyfills/streams";
import "@copilotkit/react-native/polyfills/encoding";
import "@copilotkit/react-native/polyfills/crypto";
import "@copilotkit/react-native/polyfills/dom";
import "@copilotkit/react-native/polyfills/location";

Quick start

import {
  CopilotKitProvider,
  useAgent,
  useCopilotKit,
} from "@copilotkit/react-native";

export default function App() {
  return (
    <CopilotKitProvider runtimeUrl="https://your-server/api/copilotkit">
      <ChatScreen />
    </CopilotKitProvider>
  );
}

Re-exports hooks from @copilotkit/react-core: useAgent, useFrontendTool, useComponent, useHumanInTheLoop, useInterrupt, useSuggestions, useConfigureSuggestions, useAgentContext, useThreads, and useCopilotKit.

API Surface

The root import (@copilotkit/react-native) IS the v2 API. Unlike the web SDK which has /v2 subpath, React Native exports the v2 API directly from the package root.

Documentation

For full setup instructions, usage examples, and troubleshooting, see the React Native docs.