Skip to main content
Vertz generates a fully typed SDK from your entity and service definitions. The SDK is a thin layer over an HTTP client — every method returns typed Result values, integrates with query() and form(), and provides deterministic cache keys for the UI layer.

Always use FetchClient or the generated SDK

Never use raw fetch() for API calls in your UI code. Always use FetchClient (or the generated SDK which uses it internally).During SSR, Vertz intercepts fetch() calls to route API requests through the in-memory handler — no HTTP round-trip. FetchClient is designed for this: it passes relative URLs as strings (not Request objects) so the SSR fetch proxy can intercept them. Raw fetch() bypasses proper error handling, retry logic, and SSR integration.
If codegen is not set up yet, create a FetchClient instance directly:

How it works

1

Define entities and services

Your server-side entity and service definitions are the source of truth for types, routes, and validation schemas.
2

SDK is generated

The codegen reads your definitions and produces TypeScript files — typed methods for every CRUD operation and custom action on entities, plus service operations.
3

UI consumes the SDK

Import the generated client in your UI code. Use it with query() for data fetching and form() for mutations.

Generated client

The SDK produces a client factory:
Each entity becomes a property with typed CRUD methods:
Every method returns Result<T, FetchError> — never throws for HTTP errors.

SDK + query()

SDK methods return QueryDescriptor objects that work directly with query():
The descriptor carries a deterministic cache key derived from the HTTP method, path, and sorted query parameters. This enables automatic cache deduplication — two components calling api.tasks.list({ status: 'todo' }) share the same cache entry.

SDK + form()

SDK methods carry metadata that form() uses for validation:
The codegen attaches the entity’s input validation schema to the method’s metadata. form() extracts it automatically — no need to pass a schema option unless you want to override it.

FetchClient

Under the hood, the SDK uses FetchClient — a typed HTTP client you can also use directly:

Methods

Request options

Error handling

HTTP errors are returned as typed Result values:
Error classes map 1:1 to HTTP status codes:
StatusError class
400BadRequestError
401UnauthorizedError
403ForbiddenError
404NotFoundError
409ConflictError
422UnprocessableEntityError
429RateLimitError
500InternalServerError
503ServiceUnavailableError

Retry configuration

Supports 'exponential', 'linear', or a custom function:

Lifecycle hooks

Streaming

For real-time data, the client supports SSE and NDJSON streaming:

Pagination

List endpoints return ListResponse<T>: