Get Started
Zeta provides a type-safe client for full-stack apps.
If your server and client code are in different codebases, you'll have to generate your client using openapi-generator and your OpenAPI spec.
If your server and client code are in the same codebase, you can take advantage of Zeta's built-in, lightweight wrapper around fetch to create a type-safe client.
It's really easy to use the built-in client. Import createClient from @aklinker1/zeta/client and provide it your app's type. Here's an example setup:
// server/app.ts
;
;
;
// app/utils/app-client.ts
;
;
;
DANGER
It is extremely important that you useimport typeinstead ofimportwhen importing your app's type. Otherwise, your entire backend code will be included in your frontend JS.
Once you have a client, usage is simple. Your client has one function, fetch, that accepts three arguments:
method – The HTTP method to use when making the request.route – The route to make the request to.inputs – The path params, query params, and request body to send with the request.The function returns a Promise that resolves to the response body – no need to call .json() or .text().
;