Skip to content
IC Reactor

createClient

createClient(options): Client

Defined in: core/src/client.ts:827

Creates a client: who calls, on which network, with which cache.

Say who calls with exactly one of identity and auth. auth takes a factory, which the client calls on first use and only in a browser, so the same createClient(...) line runs in a server render (anonymous, no auth built) and in the browser (signed in).

Build one client per browser tab, or one per request on a server: a client’s cache and agents belong to whoever it calls as, and two clients share neither.

ClientOptions

Client

TypeError for options that do not say who calls, say it twice, or name a network or maxDepth that cannot be used.

import { AuthClient } from "@icp-sdk/auth/client"
import { createClient } from "@ic-reactor/core"
const client = createClient({ network: "ic", auth: () => new AuthClient() })
client.subscribe(() => console.log(client.authState()))
await client.signIn()