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

# lazy()

> **lazy**<`T`>(`factory`): () => `T`

Defers building a value until first use and memoizes the result. The modules' schemas
are declared as `const s = lazy(() => wire({...}))`, with the `@__PURE__` annotation on the call, and
used as `s()`. Importing the SDK builds no schema (no top-level side effects),
so whoever imports only `isEnginexError` does not pull Zod into the bundle. It also makes the strict-schemas
flag of the contract tests work if it is turned on after the import, as long as it is before the first
request. For SDK packages (via `@getenginex/sdk/extension`), not for apps.

## Type Parameters

### T

`T`

## Parameters

### factory

() => `T`

## Returns

() => `T`

## Example

```ts
const gameSchema = lazy(() => wire({ game_id: z.string(), name: z.string() }))
transport.request({ method: 'GET', path: '/casino/games/g-1', schema: gameSchema() })
```
