Navios Builder
@navios/builder turns a description of an HTTP endpoint — method, URL, schemas — into a typed function that validates what it sends and what it receives. You write the description once and use it from the browser, from a Navios server controller and from React Query hooks.
One declaration, three places
The value getUser is the contract. Everything else is derived from it.
Call it from any TypeScript code:
Implement it in a Navios server controller. The handler's parameters and return type come from the same declaration:
Use it as a React Query hook:
Change the response schema and all three stop compiling until they agree again.
What you get
- Inferred types. Arguments, results and error bodies are inferred from the URL template and the schemas. You never write a request or response type by hand.
- Validation on both sides of the wire. Input is checked before a request is sent; the response is checked before your code sees it.
- One error type. Every failed call is an
EndpointErrorwith akindyou can switch on. Let it throw, or call.safe()and receive it as a value. - Your schema library. Every schema slot accepts any Standard Schema implementation: Zod, Valibot, ArkType and others. These docs use Zod in examples.
- Your HTTP client.
@navios/http, axios, or a smallfetchwrapper. - More than JSON. Multipart uploads, file downloads, text, streams and empty replies come from the same
declareEndpoint. WebSocket and Server-Sent Events have their own typed builders.