Frontend client

Frontend client

Overview of the generated, typed TypeScript client - what it is, how it fits your frontend, and where to read more.

Read as Markdown

@aventara/client is a development-time generator. It reads your deployed server's client contract and writes a standalone, typed TypeScript client into your project. The generated code imports nothing from @aventara/client or @aventara/core at runtime, so @aventara/client stays a dev dependency.

Code
import avClient from "./api/AvClient";

const users = await avClient.User.find.many({ where: { email: { contains: "example.com" } } });

Calls resolve to the data (a record, a list, a count; a first-style miss is null) and everything else throws a typed error. Only what your server advertises exists on the client, in the type and at runtime, and a where offers each field only the operators it allows. When the contract carries field validators, the client checks them before it sends a call, and throws the same AvValidationError the server would answer.

In this section

PageRead it for
Client setupavclient init, framework.client.ts, how to import the client, Vite, Next.js, Node and CORS
Typed callsavClient.User.find.many, named types, readonly results, typing helpers
Client errorsThe error classes and how to handle them
Client optionsnew AvClient({ entrypoint, fetch }), AvCallOptions, authentication, aborting
Keeping in syncRegenerating, "up to date", CI checks, what a stale client does

For the query language itself see Querying; for atomic multi-step writes see Transactions.

See also