Quick start
Install the router, write a first service, and serve it on Cloudflare Workers, Node, Deno or Bun.
Install
Section titled “Install”Start with the router and the HTTP building blocks; add other packages when you need them.
npm install @edgetime/router @edgetime/httpWrite the routes
Section titled “Write the routes”Keep the routes in a module that imports nothing from a platform. Each runtime then gets a small entry file that serves them.
import { errorHandler, readJson } from '@edgetime/http';import { Router } from '@edgetime/router';
export const app = new Router() .get('/health', (c) => c.json({ status: 'ok' })) .get('/hello/:name', (c) => c.text(`Hello, ${c.params.name}`)) .post('/echo', async (c) => { const body = await readJson(c.req, { limit: 16 * 1024 }); return c.json({ received: body }, 201); }) .onError(errorHandler());app.fetch(request, env?, ctx?) never rejects and always resolves to a Response. A path that
is not registered gets 404; one registered under another method gets 405 with Allow.
A body over the limit gets 413 and malformed JSON 400. errorHandler() renders every error as RFC 9457
problem details.
Serve it
Section titled “Serve it”Cloudflare Workers
Section titled “Cloudflare Workers”import { app } from './app.ts';
export default { fetch: app.fetch } satisfies ExportedHandler;{ "$schema": "node_modules/wrangler/config-schema.json", "name": "my-service", "main": "src/index.ts", "compatibility_date": "2026-11-27"}npx wrangler devThe router passes env and ctx through to handlers as c.env and c.ctx. See
Deploy on Workers for bindings and the composition root.
npm install @edgetime/nodeimport { serve } from '@edgetime/node';import { app } from './app.ts';
const server = await serve(app.fetch, { port: 3000, env: {} });process.once('SIGTERM', async () => process.exit((await server.shutdown()) ? 0 : 1));node src/server.tsNode 24.13 runs TypeScript sources directly. See Run on Node.
Deno and Bun
Section titled “Deno and Bun”Both serve fetch handlers natively. Pass only the request, since their second argument is not an
env:
// DenoDeno.serve((request) => app.fetch(request));
// BunBun.serve({ fetch: (request) => app.fetch(request) });- Add the middleware most services want:
requestId(),accessLog()andsecureHeaders(). - Type the app’s
envandvars, and read dependencies through providers. - Read Architecture for how the packages fit together.