For AI agents: the complete documentation index is available at https://navios.tech/llms.txt, the full documentation bundle is available at https://navios.tech/llms-full.txt, and this page is available as Markdown at https://navios.tech/docs/builder/index.md.

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.

import { builder } from '@navios/builder'
import { create } from '@navios/http'
import { z } from 'zod/v4'

const API = builder({ client: create({ baseURL: 'https://api.example.com' }) })

export const getUser = API.declareEndpoint({
  method: 'GET',
  url: '/users/$userId',
  responseSchema: z.object({ id: z.string(), name: z.string() }),
})

const user = await getUser({ urlParams: { userId: '42' } })
//    ^? { id: string; name: string }

One declaration, three places

The value getUser is the contract. Everything else is derived from it.

Call it from any TypeScript code:

const user = await getUser({ urlParams: { userId: '42' } })

Implement it in a Navios server controller. The handler's parameters and return type come from the same declaration:

import { Controller, Endpoint } from '@navios/server'

import type { HandlerParams } from '@navios/server'

@Controller()
class UserController {
  @Endpoint(getUser)
  async getUser({ urlParams }: HandlerParams<typeof getUser>) {
    return { id: urlParams.userId, name: 'Ada' }
  }
}

Use it as a React Query hook:

import { declareClient } from '@navios/react-query'

const client = declareClient({ api: API })
const userQuery = client.query(getUser)

function UserName({ userId }: { userId: string }) {
  const { data } = userQuery.use({ urlParams: { userId } })
  return <span>{data?.name}</span>
}

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 EndpointError with a kind you 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 small fetch wrapper.
  • 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.

Where to go

You want to…Read
get an endpoint workingQuick start
understand the model firstHow it works
learn the everyday API in orderEssentials, starting with Declaring endpoints
find out why a call failedErrors
share declarations with a Navios serverSharing with Navios Server
use endpoints in React componentsReact Query
look up an option, type or exportAPI reference
upgrade from 1.xMigrating to 2.0