Documentation / @super-line/react / useSuperLineClient
Function: useSuperLineClient()
useSuperLineClient<
C,R>(make,deps?):SuperLineClient<C,R> |null
Defined in: index.ts:140
StrictMode-safe client ownership: builds the client in a COMMITTED effect, closes it in that effect's cleanup, and rebuilds when deps change — so StrictMode's dev-mode effect cycle (mount → cleanup → re-run) opens and closes a real socket once extra but never leaks one, and a client constructed during a render React later discards is never created at all. make is read via a ref: an inline arrow is safe, deps alone drive rebuilds.
Returns null until the first commit (and between rebuilds) — exactly the state every hook in this package idles on, and what SuperLineProvider accepts. Construction connects, so this is the ONLY way to own a client from React that survives StrictMode; a useState(() => createSuperLineClient(…)) initializer leaks a connected socket every double-invoked render.
Type Parameters
C
C extends Contract
R
R extends string
Parameters
make
() => SuperLineClient<C, R>
deps?
readonly unknown[] = []
Returns
SuperLineClient<C, R> | null