Documentation / @agentick/core / useComState
Function: useComState()
useComState<
T>(key,initialValue,options?):Signal<T>
Defined in: core/src/hooks/com-state.ts:57
Use state stored in the COM.
Type Parameters
T
T
Parameters
key
string
Unique key for this state in the COM
initialValue
T
Initial value if not already set
options?
Persistence options
Returns
Signal<T>
A Signal-like object for reading and writing the state
Examples
tsx
function StatusComponent() {
const status = useComState('status', 'pending');
// Read the value
console.log(status()); // or status.value
// Update the value
status.set('active');
return <System>Status: {status()}</System>;
}tsx
// Transient UI state — don't survive persistence
const isExpanded = useComState('ui:expanded', false, { persist: false });