Multiple Source Folders
Organize distinct concerns - public site, customer app, admin dashboard - all connected in one Vite project.
Structured Vite Template. Build type-safe full-stack apps. Multiple source folders. Directory-based routing. Runtime validation. Generated fetch clients. Any framework.
id to be a number 

id to be a positive integer.TRefine to specify JSON Schema constraints. TRefine can be used to specify JSON Schema constraints. 

ctx.body should match defined schema for validation to pass. never for the first argument. slot option to allow routes to override this middleware later. Use the on option to run middleware only for specific HTTP methods. 

slot option in routes to override global middleware with the same slot name. Eg., for file upload routes, use a form body parser instead of the default JSON parser. Koa-compatible middleware β not just those provided by KosmoJS. KosmoJS is a structured Vite template that keeps your full-stack concerns aligned.
Rather than inventing yet another framework, KosmoJS integrates proven tools - TypeScript, Vite, Koa, and your frontend framework - into a clear organizational pattern. Separation of concerns isn't something you have to remember - it's built into the structure.
No proprietary abstractions. No new paradigms to learn. Just thoughtful structure around tools you already know.
π Learn more
Multiple source folders for distinct concerns - each with its own API and pages directories, eg.:
πΉ Public marketing site at /
πΉ Customer application at /app
πΉ Admin dashboard at /admin
All in one monorepo-like project, each with independent routing and configuration, yet sharing types and validation logic.
API / Pages separation keeps server and client code from mixing. Your directory structure enforces boundaries that code review can't.
π Getting started Β· Directory-based routing
At its core, KosmoJS structures full-stack Vite development around a Koa application.
πΉ Vite handles your frontend builds and organizational structure.
πΉ Koa powers your API runtime with runtype validation and middleware composition.
πΉ KosmoJS is the structured template that brings them together.
KosmoJS extends TypeScript's compile-time safety to runtime. Your type definitions become validation schemas automatically - no duplication, no drift.
Define parameter types, payload structures, and response shapes once. KosmoJS generates:
Everything stays aligned because everything derives from the same source of truth.
π Type safety overview Β· Validation Β· Payload validation
Every API route gets a fully-typed fetch client with built-in validation. Your frontend knows exactly what parameters each endpoint expects, what payload structure it accepts, and what response shape it returns.
Invalid data is caught client-side, before network requests. Your API never processes malformed requests.
π Fetch clients intro Β· Getting started Β· Client-side validation
Build APIs directly inside Vite's dev server with hot-reload support.
Slot-based middleware gives you fine-grained control - override global middleware per endpoint, compose request handling precisely, maintain consistent patterns across routes.
Development and production use the same structure - what you build locally is what deploys.
π Dev workflow Β· Middleware patterns
Enable features by adding generators to your Vite config:
Each generator watches your code and updates artifacts as you develop.
π SolidJS generator Β· OpenAPI generator
pnpm build produces deployment-ready output - bundled API server and optimized frontend assets.
Deploy to any Node.js environment: traditional servers, containers, serverless platforms, or edge runtimes.
Structure without constraints.
KosmoJS is opinionated about organization but unopinionated about implementation. Clear boundaries between API and pages. Obvious locations for shared types and utilities. Separation of concerns built into the filesystem.
You choose your frontend framework, state management, styling approach, database, and everything else.
The structure scales; your choices remain free.
π About KosmoJS Β· Features