Documentation / @super-line/client / createSuperLineClient
Function: createSuperLineClient()
createSuperLineClient<
C,R>(contract,opts):SuperLineClient<C,R>
Defined in: index.ts:207
Create a typed client for role R. Connects immediately and reconnects on its own.
Type Parameters
C
C extends Contract
R
R extends string
Parameters
contract
C
the shared contract.
opts
SuperLineClientOptions<C, R>
client options; url and role are required.
Returns
SuperLineClient<C, R>
a SuperLineClient proxy narrowed to the role's surface.
Example
ts
const client = createSuperLineClient(api, {
transport: webSocketClientTransport({ url: 'ws://localhost:3000' }),
role: 'user',
params: { token },
})
client.on('message', (m) => console.log(m.text))
const out = await client.send({ text: 'hi' }) // throws SuperLineError on failure