createClient
createClient(
options):Client
Defined in: core/src/client.ts:1303
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.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”Throws
Section titled “Throws”TypeError for options that do not say who calls, say it twice, or
name a network or maxDepth that cannot be used; for an option it does not
have (in the options or in a network object); and for an allowEnvConfig
or fetchRootKey that is not a boolean, a rootKey that is not 133 bytes
in a Uint8Array, or a fetch that is not a function.
Example
Section titled “Example”import { AuthClient } from "@icp-sdk/auth/client"import { createClient } from "@ic-reactor/core"
const client = createClient({ network: "ic", auth: (network) => new AuthClient(network) })client.subscribe(() => console.log(client.authState()))await client.signIn()