# wend

> Typed, composable HTTP routing for `(req, res)` and `Request`/`Response` handlers. One immutable builder with compile-time path-param inference and typed context accumulation; a runtime-agnostic core with two native adapters — `@ricokahler/wend/node` (mutate `res`) and `@ricokahler/wend/fetch` (return `Response`).

Import from a runtime adapter. `@ricokahler/wend/node` covers node:http, Express, Next.js pages API, Fastify (raw), Google Cloud Functions. `@ricokahler/wend/fetch` covers Cloudflare Workers, Deno, Bun, Next.js App Router. The builder (`.with`/`.match`/`.serve`), param inference, and middleware model are identical in both. Requires Node 18+; one dependency (`path-to-regexp`).

## Docs

- [README](README.md): install, the idea, per-runtime examples, typed params, middleware, nested routes, errors, API reference, compatibility table.
- [SKILL.md](SKILL.md): agent-focused usage guide — choose the adapter, mental model, core API, copy-paste recipes, gotchas. A Claude Agent Skill; usable by any agent.
- [AGENTS.md](AGENTS.md): repo layout, commands, conventions, and a pointer to SKILL.md.

## Source

- [src/index.ts](src/index.ts): runtime-agnostic core — `Router` builder, path-param inference, middleware, `RouteNotFoundError`/`HttpError`, `errorBoundary`.
- [src/node.ts](src/node.ts): `@ricokahler/wend/node` adapter — `createNodeHandler` + typed helpers.
- [src/fetch.ts](src/fetch.ts): `@ricokahler/wend/fetch` adapter — `createFetchHandler` + typed helpers.
