# createClient

> **createClient**(`options`): [`Client`](https://ic-reactor.b3pay.net/v4/libs/interfaces/client/)

Defined in: [core/src/client.ts:827](https://github.com/B3Pay/ic-reactor/blob/6b3b9f58b7868082175216ca6e3688d278d17c1f/packages/core/src/client.ts#L827)

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

### options

[`ClientOptions`](https://ic-reactor.b3pay.net/v4/libs/type-aliases/clientoptions/)

## Returns

[`Client`](https://ic-reactor.b3pay.net/v4/libs/interfaces/client/)

## Throws

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

## Example

```ts
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()
```