Variable: AgentContext
typescript
1
const AgentContext: Context<undefined | { agent: null | Agent; setAgent: (agent) => void; start: () => Promise<void>; state: State; stop: () => Promise<void>; }>
Defined in: packages/identus-react/src/context/index.ts:316
React context for managing the main Identus Agent operations.
The Agent is the central orchestrator for all Identus SDK operations including DIDComm messaging, credential operations, and connection management. This context provides access to agent lifecycle management and core functionality.
Example
tsx123456789101112131415161718192021222324252627282930313233import { AgentContext } from '@trust0/identus-react/context';import { useContext } from 'react';function AgentManager() {const context = useContext(AgentContext);if (!context) {throw new Error('AgentManager must be used within AgentProvider');}const { agent, start, stop, state, setAgent } = context;const handleStart = async () => {try {await start();console.log('Agent started successfully');} catch (error) {console.error('Failed to start agent:', error);}};return (<div><p>Agent State: {state}</p><button onClick={handleStart} disabled={state === 'running'}>Start Agent</button><button onClick={stop} disabled={state !== 'running'}>Stop Agent</button></div>);}