Kynetra FX

Documentation

Overview

Kynetra FX is a TypeScript web framework built entirely on the Request / Response Web Standards. Write your application once; deploy it to Cloudflare Workers, Node.js, Bun, Deno, or any other conforming runtime without changing a line.

What it is#

Kynetra FX (@kynetra/fx) is not a Hono wrapper, an Express port, or a thin adapter layer. It is a ground-up framework synthesised from the best ideas in 11 existing frameworks — optimised for the edge-first, multi-runtime world. The surface area is deliberately small: a router, a context object, middleware composition, and a typed contract layer. Everything else (auth, RBAC, SaaS kernel, AI, WASM guests, typed clients) ships as first-party packages that all speak the same ctx type.

The Web-Standards thesis#

Every handler receives a ctx whose ctx.req is a plain Request and whose helpers return a plain Response. app.fetch(request) is itself a standard fetch handler — you can pass it directly to Bun.serve, Deno.serve, or export it as a Cloudflare Worker default export with no glue code. This means your application is testable with new Request() in any environment — no mocking required.

30-second example#

app.ts
import { createFX } from '@kynetra/fx'
 
const app = createFX({ name: 'my-app' })
 
app.get('/', (ctx) => ctx.json({ hello: 'world' }))
 
app.get('/users/:id', (ctx) => {
const { id } = ctx.params
return ctx.json({ id, name: 'Alice' })
})
 
// Direct fetch — works everywhere
return { fetch: app.fetch }

That is a complete, deployable application. No class decorators, no build step, no runtime-specific glue.

The 18-package map#

Kynetra FX is published as a set of focused packages. Import from the umbrella @kynetra/fx for everything in the core, or pull only what you need.

  • @kynetra/fx — router, context, middleware, contracts, schema builder, plugins/hooks, OpenAPI, typed client.
  • @kynetra/fx-auth — JWT, API-key, and session authentication strategies; Principal model.
  • @kynetra/fx-rbac — role definitions, can(), per-route permission guards.
  • @kynetra/fx-saas — multi-tenant SaaS kernel: users, orgs, memberships, feature flags, audit logs.
  • @kynetra/fx-ports — portable interfaces (KV, cache, queue, blob, vector, SQL) with in-memory fakes.
  • @kynetra/fx-aiAiPort, provider adapters (OpenAI, Anthropic, Workers AI), RAG helper.
  • @kynetra/fx-wasm — polyglot WASM guest handlers (ClearScript, NovaC, KYRx).
  • @kynetra/fx-cloudflare — Cloudflare Workers adapter, D1 SQL/store adapters.
  • @kynetra/fx-node — Node.js http adapter.
  • @kynetra/fx-clikynetra new project scaffolder.
  • @kynetra/fx-plugindefinePlugin helper re-exported from core.

Tip

Most projects only need @kynetra/fx plus one runtime adapter (e.g. @kynetra/fx-cloudflare). Add other packages only when you need their features.

Key concepts at a glance#

Routes and handlers

Routes are registered with app.get, app.post, etc. Each handler receives a typed ctx and returns a Response. Multiple handlers on the same route act as per-route middleware; the last is the terminal handler. See Routing for full details.

Middleware

app.use(mw) registers app-level middleware. Middleware follows the onion model: call await next() to pass control inward, then optionally mutate the response on the way back out. Built-ins include cors(), logger(), requestId(), and secureHeaders(). See Middleware.

Contracts

app.route({ method, path, input, query, handler }) validates request bodies and query strings automatically and exposes the typed values on ctx.input and ctx.validatedQuery. The same contract metadata feeds generateOpenAPI() and the typed client. See Contracts.

Where to go next#

  • Why Kynetra FX — the design philosophy and when to choose it.
  • Installation — requirements and package setup.
  • Quickstart — build and deploy your first app in minutes.
  • Routing — static, dynamic, and wildcard routes.
  • Middleware — built-ins and custom composition.
  • Contracts — validation, OpenAPI, and typed clients.
  • Playground — run Kynetra FX live in the browser.
Overview · Kynetra FX