Kontas is a minimalist and high-performance web framework designed specifically for the Bun JavaScript runtime. Currently at version 0.1.149, it focuses on providing a simple, Koa-style asynchronous middleware pipeline and routing for building web applications with Bun. Its core differentiator lies in its commitment to simplicity, speed, and native Bun integration, leveraging Bun's fast JavaScriptCore engine and built-in Web API compatibility. While its pre-1.0 version suggests a rapid release cadence with potential API evolution, Kontas aims to offer an elegant, developer-friendly experience for backend development, contrasting with more opinionated or heavier frameworks. It's ideal for projects prioritizing raw performance and a lightweight footprint within the Bun ecosystem, offering an alternative to frameworks like Elysia or Hono by emphasizing minimalism.
npm install kontasVerified import paths — ran on the pinned version, not inferred.
This quickstart sets up a basic Kontas server with a root GET route, a route with a path parameter, and a global middleware for logging requests. It demonstrates the core application setup and routing, highlighting TypeScript usage for context and middleware.
Consult the project's GitHub repository or NPM page for the latest API documentation before upgrading. Use `bun add kontas@<exact-version>`.
Ensure your project is configured to use Bun (e.g., `bun run <script>`). Do not attempt to run Kontas applications with `node`.
Review the Kontas documentation on error handling patterns. Implement global error middleware or specific try-catch blocks where necessary.
Check Kontas's documentation for official body parsing middleware. If none exists, implement a custom middleware to parse JSON, form data, or other request bodies using Web Standard `Request` methods like `request.json()` or `request.formData()`.
Replace `const Kontas = require('kontas');` with `import Kontas from 'kontas';`. Ensure all local files are also using ESM syntax or have `.cts` / `.mts` extensions if mixed modules are strictly necessary.Change the port in `app.listen(PORT, ...)` to an available one (e.g., 8000), or terminate the process currently using the port (`lsof -i :3000` on macOS/Linux, then `kill <PID>`).
Ensure middleware functions and route handlers correctly receive and pass the `Context` object. Verify the `Context` type definition and object structure in the Kontas documentation. Explicitly type `ctx: Context` to catch issues at compile-time.