Using StreamLayer Context
Access the StreamLayer SDK core context via the useStreamLayer React hook to call SDK methods programmatically.
Overview
The useStreamLayer hook provides access to the StreamLayer SDK core context. Use it to call SDK methods programmatically — for example, to create event sessions or manage SDK state from your own components.
Usage
import { useStreamLayer } from '@streamlayer/react'
const EventInput = () => {
const sdk = useStreamLayer()
const [event, setEvent] = useState('')
const startEventSession = () => {
sdk.createEventSession(event)
}
return (
<div>
<input type="text" value={event} onChange={e => setEvent(e.target.value)} />
<button onClick={startEventSession}>set</button>
</div>
)
}Related
- Using StreamLayer UI Context — Access UI state flags
- Integration Guide — Full Web SDK setup
Updated 21 days ago
