MCPcopy
hub / github.com/CopilotKit/CopilotKit / useCopilotKit

Function useCopilotKit

packages/react-core/src/v2/context.ts:28–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26);
27
28export const useCopilotKit = (): CopilotKitContextValue => {
29 const context = useContext(CopilotKitContext);
30 const [, forceUpdate] = useReducer((x: number) => x + 1, 0);
31
32 if (!context) {
33 throw new Error("useCopilotKit must be used within CopilotKitProvider");
34 }
35 useEffect(() => {
36 const subscription = context.copilotkit.subscribe({
37 onRuntimeConnectionStatusChanged: () => {
38 forceUpdate();
39 },
40 onHeadersChanged: () => {
41 forceUpdate();
42 },
43 });
44 return () => {
45 subscription.unsubscribe();
46 };
47 // eslint-disable-next-line react-hooks/exhaustive-deps
48 }, []);
49
50 return context;
51};
52
53// License context — shared between web and RN providers.
54// Default is permissive (all features allowed) — providers override via createLicenseContextValue.

Callers 15

CopilotListenersFunction · 0.90
CopilotKitErrorBridgeFunction · 0.90
useSuggestionsFunction · 0.90
useThreadsFunction · 0.90
useInterruptFunction · 0.90
useConfigureSuggestionsFunction · 0.90
useLearningContainersFunction · 0.90
useFrontendToolFunction · 0.90
useRenderToolFunction · 0.90
useAgentFunction · 0.90
useAgentContextFunction · 0.90
useHumanInTheLoopFunction · 0.90

Calls 2

subscribeMethod · 0.65
unsubscribeMethod · 0.65

Tested by 15

AbortHITLComponentFunction · 0.72
RunAgentHarnessFunction · 0.40
CollectorFunction · 0.40
SpyAttacherFunction · 0.40
ChildFunction · 0.40
DynamicToolChildFunction · 0.40
DynamicRenderChildFunction · 0.40
CollectorFunction · 0.40
SnapshotRendererFunction · 0.40
CoreCaptureFunction · 0.40
StaticSuggestionsHarnessFunction · 0.40

Used in the wild real call sites across dependent graphs

searching dependent graphs…