Documentation / @super-line/client / createClient
Function: createClient()
createClient<
C,R>(contract,opts):Client<C,R>
Defined in: packages/client/src/index.ts:161
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
ClientOptions<C, R>
client options; url and role are required.
Returns
Client<C, R>
a Client proxy narrowed to the role's surface.
Example
ts
const client = createClient(api, { url: 'ws://localhost:3000', role: 'user', params: { token } })
client.on('message', (m) => console.log(m.text))
const out = await client.send({ text: 'hi' }) // throws SocketError on failure