---
url: https://game-engine-io.github.io/enginex-frontend-sdk/core.md
---
# Core

`@getenginex/sdk` is the core of the SDK: the client (`createEnginexClient`), the session and its tokens,
the tenant, errors and the flows every player app needs, independent of product: account, operator
configuration, wallet and PIX, KYC, responsible gaming, notifications and realtime. The product packages
([iGaming](/igaming/) and [Predictions](/predictions/)) and the framework adapters
([Frameworks](/frameworks/)) are built on top of it.

| Namespace | What it does |
| --- | --- |
| `auth` | [sign-up](/flows/sign-up), [login and 2FA](/flows/login) and [password](/flows/password) |
| `config` | [operator configuration and branding](/flows/config-branding); the [support widget](/flows/support) |
| `profile` | the player's [profile and sessions](/flows/profile) |
| `wallet`, `deposits` | balance and statement; [PIX deposit](/flows/pix-deposit) ([live balance](/flows/live-balance)) |
| `withdrawals` | [withdrawal](/flows/withdrawal) with OTP |
| `pixKeys` | the player's [PIX keys](/flows/pix-keys) |
| `kyc` | [identity verification](/flows/kyc) |
| `responsibleGambling` | [responsible gaming](/flows/responsible-gaming) |
| `notifications` | [notifications](/flows/notifications) |

## Installation

```bash
npm i @getenginex/sdk
# or
pnpm add @getenginex/sdk
```

The core has **no peer dependencies**. Its only dependency is `zod` 4 (a regular dependency, shared with the
product packages when the ranges match; see [a single `zod` copy](/guide/installation#single-zod-copy)).

* **Runtimes:** browsers with `fetch` and `AbortController`, Node 20+, edge runtimes and Bun, as ESM and
  CommonJS.
* **`crypto.randomUUID`:** only the methods that send an `Idempotency-Key` (the ones that move money, such as
  `deposits.createPix`) generate keys. Without `randomUUID` (an insecure origin, such as HTTP on the LAN) the SDK
  falls back to `crypto.getRandomValues`; with no Web Crypto at all, those methods reject with
  `CONFIGURATION_ERROR`.
* **Gateway:** by default the SDK calls `/api/v1/...` on the page's own origin. Proxy `/api` to the EngineX
  gateway ([Proxy to the gateway](/guide/installation#gateway-proxy)).

## Entry points

| Import | What it brings |
| --- | --- |
| `@getenginex/sdk` | `createEnginexClient`, token stores, `EnginexError`/`isEnginexError` and the namespaces above |
| `@getenginex/sdk/realtime` | `createRealtime` and `coreTopics` ([Realtime](/concepts/realtime)) |
| `@getenginex/sdk/query` | query and mutation factories for TanStack Query v5 ([Frameworks](/frameworks/#queries-layer)) |
| `@getenginex/sdk/testing` | `createMockFetch` and `createMockRealtime` ([Testing and mocks](/guide/testing)) |
| `@getenginex/sdk/extension` | the contract for SDK packages, not for apps ([Extensibility](/concepts/extensibility#product-packages)) |

Each entry is a separate file: an app that does not import `/realtime` loads no WebSocket code, and
`/testing` never reaches a production bundle that does not import it.

## Create the client

Create **one** client per app in the browser and export it:

```ts
// enginex.ts
import { createEnginexClient, localStorageTokenStore } from '@getenginex/sdk'

export const enginex = createEnginexClient({
  locale: 'pt-BR',
  tokenStore: localStorageTokenStore(),
  onSessionExpired: () => location.assign('/login'),
})

const config = await enginex.config.get()
```

On the server (SSR, scripts, tests), create one client per request, with `baseUrl` and `tenantHost`. The
full walkthrough (login, session, language and disposal) is in [Getting started](/guide/getting-started);
the options are in [Session and tokens](/concepts/session) and [Tenant and domains](/concepts/tenant).

## Products and frameworks

The product packages take the core client and reuse its session, tenant, hooks and validation:

```ts
import { createIgaming } from '@getenginex/sdk-igaming'
import { createPredictions } from '@getenginex/sdk-predictions'

export const igaming = createIgaming(enginex)
export const predictions = createPredictions(enginex)
```

They declare the core as a *peer dependency* (`>=0.6.0 <1.0.0`): install the core once, at the top of the
app. For React, Next.js and Vue, see [Frameworks](/frameworks/).

## Testing

`@getenginex/sdk/testing` runs the whole client without a gateway: `createMockFetch()` answers the core
routes with data that passes the SDK's schemas, and `createMockRealtime()` is a fake `WebSocket`. See
[Testing and mocks](/guide/testing).
