---
url: >-
  https://game-engine-io.github.io/enginex-frontend-sdk/reference/api/@getenginex/sdk-next/server/functions/getEnginexServer.md
---
[Reference](../../../../index.md) / [@getenginex/sdk-next/server](../index.md) / getEnginexServer

# getEnginexServer()

> **getEnginexServer**(`options?`): `Promise`<[`EnginexClient`](../../../sdk/interfaces/EnginexClient.md)>

EngineX client for Server Components, Server Actions and Route Handlers of the App Router: one per request,
with the tenant taken from the request headers and anonymous by default (it does not read cookies, does not renew the session).

* **Tenant:** `host` → `x-forwarded-host` from `headers()`. `x-original-host` only counts with
  `trustOriginalHost` (it can come from the browser); `resolveHost` replaces everything.
* **Gateway:** `baseUrl` or the `ENGINEX_GATEWAY_URL` environment variable (absolute URL).
* **Per request:** memoized with React's `cache()`. Within the same request, calls with equal options
  return the same client (the `tags` compared by content, `resolveHost` and `tokenStore` by
  reference); different options, different clients. Different requests never share a client.
* **Next cache:** `next: { revalidate, tags }` goes on every `fetch`.

Reading `headers()` makes the route dynamic, like any per-tenant data.

## Parameters

### options?

[`GetEnginexServerOptions`](../interfaces/GetEnginexServerOptions.md) = `{}`

Gateway, `fetch` cache, tenant discovery, tokens and language.

## Returns

`Promise`<[`EnginexClient`](../../../sdk/interfaces/EnginexClient.md)>

Promise of the current request's client.

## Throws

`CONFIGURATION_ERROR` (rejected promise) without an absolute `baseUrl` or without a tenant
in the request, before any `fetch`.

## Example

```ts
// app/page.tsx (Server Component)
import { getEnginexServer } from '@getenginex/sdk-next/server'

export default async function Page() {
  const enginex = await getEnginexServer({ next: { revalidate: 300, tags: ['config'] } })
  const config = await enginex.config.get()
  return <p>Currency: {config.defaultCurrency}</p>
}
```
