Kynetra FX

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#

terminal
npm install @kynetra/fx
# or
pnpm add @kynetra/fx
# or
bun add @kynetra/fx

The @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.

terminal
# Cloudflare Workers / Pages
npm install @kynetra/fx-cloudflare
 
# Node.js http server
npm install @kynetra/fx-node
 
# Bun and Deno no adapter needed, use app.fetch directly

Optional 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-clikynetra new project scaffolder.

TypeScript setup#

Kynetra FX requires strict mode. A minimal tsconfig.json for a Cloudflare Workers project:

tsconfig.json
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "Bundler",
"lib": ["ES2022"],
"strict": true,
"noUncheckedIndexedAccess": true,
"outDir": "dist"
},
"include": ["src"]
}

Note

If you are targeting Node.js, add "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:

terminal
npx @kynetra/fx-cli new my-api --runtime cloudflare
cd my-api
npm install
npm run dev

This 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:

NameTypeDescription
namestringHuman-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.
app.ts
import { createFX } from '@kynetra/fx'
 
const app = createFX({
name: 'payments-api',
runtime: 'cloudflare',
mode: 'edge',
})

Tip

Ready to write your first route? Head to the Quickstart.