Skip to content

useLume

useLume() gives you access to Lume controls and context updates from any component inside LumeProvider. It throws if called outside a provider.


import { useLume } from '@ovt2/lume'
function MyComponent() {
const { setContext, pushContext, open } = useLume()
}

MethodTypeDescription
setContext(ctx)(ctx: Record<string, ...>) => voidReplace the entire context object
mergeContext(partial)(partial: Record<string, ...>) => voidUpdate specific keys without replacing the whole context
pushContext(note)(note: string) => voidInject a hidden note into the conversation
open()() => voidOpen the chat panel
close()() => voidClose the chat panel
toggle()() => voidToggle open/closed
clearHistory()() => voidClear all messages

If you need to call useLume in a component that might render outside the provider, use useLumeSafe — it returns null instead of throwing:

import { useLumeSafe } from '@ovt2/lume'
function OptionalHelper() {
const lume = useLumeSafe()
if (!lume) return null
return <button onClick={lume.open}>Get help</button>
}