Documentation
Installation
Kynetra FX runs on any runtime that implements the Web Standards Request / Response API — Cloudflare Workers, Node.js 18+, Bun, and Deno. Install the umbrella package to get started.
Requirements#
- TypeScript 5.0+ — Kynetra FX uses const type parameters and satisfies expressions.
- Any Web-Standards runtime — Cloudflare Workers, Node.js 18+, Bun 1.0+, or Deno 1.35+.
- No build step required for basic use — a bundler (esbuild, Vite, Wrangler) is needed for Cloudflare Workers deployment.
Install the core package#
npm install @kynetra/fx# orpnpm add @kynetra/fx# orbun add @kynetra/fxThe @kynetra/fx package includes the router, context, middleware composition, the contract/schema layer (fx.*), built-in middleware, OpenAPI generation, typed client, and the plugin system. For most projects this is the only package you need to start.
Runtime adapters#
Install the adapter for your target runtime. You do not need more than one unless your project deploys to multiple targets.
# Cloudflare Workers / Pagesnpm install @kynetra/fx-cloudflare # Node.js http servernpm install @kynetra/fx-node # Bun and Deno — no adapter needed, use app.fetch directlyOptional packages#
Install additional first-party packages only when you need their features. They all share the same ctx type and integrate with the same plugin system.
@kynetra/fx-auth— JWT, API-key, and session authentication.@kynetra/fx-rbac— role-based access control.@kynetra/fx-saas— multi-tenant SaaS kernel.@kynetra/fx-ports— portable KV, queue, blob, vector, SQL interfaces.@kynetra/fx-ai— AI completion/embedding port and RAG helper.@kynetra/fx-wasm— polyglot WASM guest handlers.@kynetra/fx-cli—kynetra newproject scaffolder.
TypeScript setup#
Kynetra FX requires strict mode. A minimal tsconfig.json for a Cloudflare Workers project:
{ "compilerOptions": { "target": "ES2022", "module": "ESNext", "moduleResolution": "Bundler", "lib": ["ES2022"], "strict": true, "noUncheckedIndexedAccess": true, "outDir": "dist" }, "include": ["src"]}Note
"types": ["node"] and install @types/node. For Cloudflare Workers, install @cloudflare/workers-types and add "types": ["@cloudflare/workers-types"].Scaffold a new project#
The CLI can scaffold a complete project skeleton for any supported runtime:
npx @kynetra/fx-cli new my-api --runtime cloudflarecd my-apinpm installnpm run devThis creates a project with a working app.ts, a wrangler.toml (for Cloudflare), and example routes. See Quickstart for a walkthrough, or Project Structure for layout recommendations.
createFX options#
The createFX(options?) factory accepts an optional configuration object:
| Name | Type | Description |
|---|---|---|
| name | string | Human-readable name for this app instance. Used in logs and error messages. |
| runtime | 'cloudflare' | 'node' | 'bun' | 'deno' | Hint to the framework about the target runtime. Optional — auto-detected in most cases. |
| mode | 'edge' | 'server' | Deployment mode hint. 'edge' opts in to edge-optimised defaults (no long-lived connections). Optional. |
import { createFX } from '@kynetra/fx' const app = createFX({ name: 'payments-api', runtime: 'cloudflare', mode: 'edge',})Tip