# Routes, RPC and the dev server

`std/ui` turns a routes directory into one function from request to response. `std/rpc` makes a typed call between the two halves. `vyrn dev` serves both while you work.

## Routes

[std/ui](https://vyrn-lang.github.io/docs/std/ui.html) reads a `routes/` directory and generates one `route(req) -> Response`. Each route gets a typed URL helper, so a link cannot name a page that is not there. A `[param].vyx` file binds a path segment, and the component decides whether the value is a page or a 404.

This site is built with it: `site/export.vyrn` calls that function once per path and writes what comes back. The same table can be served live with `vyrn serve` instead.

## RPC

[std/rpc](https://vyrn-lang.github.io/docs/std/rpc.html) generates the client and server halves of a call from one declaration. The client half runs in the page as wasm; the server half is a route. An answer is typed too: a rejection carries its validation issues attached to the fields they are about, so a form can show each problem where it belongs.

## vyrn dev

`vyrn dev` builds the client to wasm and serves the server, the static files and the runtimes in one process. `vyrn routes` prints the resolved table: every path the router mounts, each with its source. Read it first when a URL does not do what you expected.

---

From https://vyrn-lang.github.io/web/server.html — generated by `site/export.vyrn` from the Vyrn repository.
