Reference / @getenginex/sdk-next/server / getEnginexServer
getEnginexServer()
getEnginexServer(
options?):Promise<EnginexClient>
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-hostfromheaders().x-original-hostonly counts withtrustOriginalHost(it can come from the browser);resolveHostreplaces everything. - Gateway:
baseUrlor theENGINEX_GATEWAY_URLenvironment variable (absolute URL). - Per request: memoized with React's
cache(). Within the same request, calls with equal options return the same client (thetagscompared by content,resolveHostandtokenStoreby reference); different options, different clients. Different requests never share a client. - Next cache:
next: { revalidate, tags }goes on everyfetch.
Reading headers() makes the route dynamic, like any per-tenant data.
Parameters
options?
Gateway, fetch cache, tenant discovery, tokens and language.
Returns
Promise<EnginexClient>
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>
}