Documentation menu
Start here
IntroductionGetting startedWrite an agentProject anatomyUnderstand Ayjnt
Harness engineeringTwo runtimesHuman interfacesHow agents workHost bridgeAgent capabilities
Callable methodsState & SQLiteSessions & memorySchedulingWorkflowsDurable executionInter-agent RPCSub-agentsToolsWebAssembly modulesInterfaces & integrations
Browser clientRouting & middlewareVoiceBrowser toolsMCPEmailObservabilityCLI
Command overviewnewdevrunbuildcompilemigratedeployAPI reference
AgentAgentClientWorkflow classesLocal & cloudMigrationsExamplesBrowser client
Connect a co-located React interface to state and callable methods with generated types.
Generated useAgent hook
When app.tsx sits beside an agent, Ayjnt generates a route-bound useAgent() hook. It derives the instance from the URL, subscribes to state, and types stub from the server class.
import { useAgent } from "@ayjnt/counter";
export default function Counter() {
const agent = useAgent();
const count = agent.state?.count ?? 0;
return <button onClick={() => agent.stub.increment(1)}>
Count: {count}
</button>;
}AgentClient without React
Use Ayjnt’s AgentClient when you want the same WebSocket state and RPC protocol without a React hook. The wrapper translates a file route and instance into Cloudflare’s client basePath.
import { AgentClient } from "ayjnt/client";
import type CounterAgent from "./agents/counter/agent";
const client = new AgentClient<CounterAgent>({
route: "/counter",
name: "demo",
onStateUpdate: (state) => console.log(state),
});
await client.ready;
await client.stub.increment(1);