Generate the route manifest
dev, build, typecheck and xano:deploy scripts run it first, and
npm run xano:check fails when the committed file is stale. Commit xano/routes.gen.ts.
Run npx @xano/sdk routes ./xano/index.ts without --emit to list every address the file
carries: each route in its api:<canonical>/<name> form, and each realtime socket, channel and
MCP server with the call that builds it. With --json the listing returns all four kinds.
A route key is "<VERB> <name>", the endpoint’s own identity: "GET posts/{id}",
"POST posts". When two API groups both hold the same verb and name, those endpoints are keyed
"<group>:<VERB> <name>" instead.
Call an endpoint
routePathfills and encodes path params. Keys and{param}names are checked at compile time, so a renamed endpoint stops compiling instead of returning a 404.- Fetch the absolute URL, never a bare path.
routePathreturns a path such as/api:<canonical>/posts/1. A dev server proxies that path to the backend, but the published site answers it with its ownindex.html, so a bare path works in development and breaks live.routeUrl(path, baseUrl?)puts the backend in front:baseUrlwhen given, else thewindow.XANO_HOSTevery publish injects, else nothing (the path as it is, for a dev server that proxies). A/tenant/<name>base keeps its prefix. routeQuerybuilds the query string for a GET, typed byRouteInputs[key], with no SDK runtime. It drops path params and encodes lists and objects the way the endpoint reads them:`${routeUrl(routePath("GET search"), XANO_HOST)}?${routeQuery("GET search", { tags: ["a", "b"] })}`.- Import defs as types only.
import typeerases to nothing. Importing a def as a value runs itss.*andc.*calls at load time and pulls the SDK runtime into the bundle (about 65 kB gzipped). InferResponsefollows the stack. Adb.getresponse isRow | null, adb.addis the written row, and an object-literal response has those keys. Where the shape cannot be known statically, it isunknown; declareresponseShapeon the query to fix every caller. A filter chain folds into the type:withFilters(ref("rows"), fl.first())is the row.- A call carries its target’s shape.
s.function.runwith a def handle binds the target’sInferResponse.s.function.callands.tool.callhand back an error envelope instead of raising, so they bindInferResponse<target> | CallErrorEnvelope: branch on.codebefore you read a field. InferRow<typeof table>gives a table’s row type, for props and state.
The backend URL
npm run xano:deploy writes the Xano Engine’s URL into .env.local as VITE_XANO_HOST;
restart the dev server to pick it up. A deploy with --static instead injects the backend URL
into the built HTML as window.XANO_HOST, so one build serves any backend with no rebuild. The
XANO_HOST constant above reads both. See Frontend hosting.
Validate at runtime with zod
The types check what you send at compile time. To validate data at runtime too, install the zod add-on:ROUTE_SCHEMAS, CHANNEL_SCHEMAS and MESSAGE_SCHEMAS to routes.gen.ts under the
same keys, each checked against its type when you type-check:
Realtime
When the workspace has realtime servers, the same file exportssocketUrl() and
channelPath(), plus ChannelInputs and MessageInputs for their params and payloads:
socketUrl turns a tenant base URL into the socket’s own address form, which a frontend cannot
build by hand. A listen-only client must send { action: "ping" } every few minutes, or the
idle socket is closed.
For code that already holds the host, socketPath(server, { tenant? }) returns the path alone
(/ws/<canonical>), and mcpPath() does the same for an MCP server. The tables these helpers read
are exported too: REALTIME_SERVERS, CHANNELS and MCP_SERVERS, keyed by RealtimeServerName,
ChannelName and McpServerName (RouteName for ROUTES).
MCP servers
When the workspace has MCP servers, the file also exportsmcpUrl(), the frontend’s
equivalent of mcpServer().getUrl(). It lifts a tenant base URL the same way:
access-control-allow-origin: *), so per-entry auth and the server’s oauth
are what keep it private.
Next
- Every inferred shape and the
getPath/toSearchParamshelpers: authoring reference. - Serve the built frontend from Xano: Frontend hosting.