Skip to Content
Headless SDKHooksVariables (Advanced)

Variable Hooks (Advanced)

Low-level hooks for reading and writing any variable by its full namespaced ID. In most cases, prefer the scoped hooks: useResponse, useData, useQueryParam.

useVariable<T>(id)

Read/write any variable by its full namespaced ID.

const [goal, setGoal] = useVariable<string>('answers.goal') const [isMobile] = useVariable<boolean>('device.isMobile') // system vars are read-only
ReturnTypeDescription
[0]TCurrent value of the variable
[1](value: T) => voidSetter function (no-op for system variables)

useVariables()

Returns all variables across every namespace. Re-renders on ANY variable change.

This hook subscribes to every variable update. Prefer scoped hooks like useResponse or useData to avoid unnecessary re-renders.

const variables = useVariables()
ReturnTypeDescription
variablesRecord<string, VariableValue>Every variable in the store
Last updated on