koa-66

raw JSON →
1.0.1 verified Sat Apr 25 auth: no javascript

Router middleware for Koa v2 that supports Express-like HTTP verb methods (get, post, put, delete, all), param middleware, automatic OPTIONS/HEAD responses, 501/405 status codes with headers, and a plugin system for injecting middleware via config objects. It allows mounting routers on paths, supports multiple middleware as arguments or arrays, and can throw errors with status codes. Version 1.0.1 is the latest stable release, targeting Node >= 4. Alternatives like koa-router are more actively maintained.

error Router is not a constructor
cause Calling `Router()` without `new` when the package exports the constructor directly.
fix
Use new Router() instead of Router().
error require(...) is not a function
cause Attempting to use `require('koa-66')` as a function (e.g., `require('koa-66')()`) instead of instantiating with new.
fix
Use const Router = require('koa-66'); const router = new Router();
error Cannot find module 'koa-66'
cause Package not installed or missing from node_modules.
fix
Run npm install koa-66 to install the package.
error router.routes is not a function
cause Variable `router` is not an instance of Router (e.g., it's the require() result).
fix
Ensure you create a new Router instance: const router = new (require('koa-66'))()
gotcha Router must be instantiated with `new`.
fix Use `new Router()` instead of `Router()`.
deprecated The package has not been updated since 2016 and relies on Node >= 4. It may not be compatible with modern Koa v2 releases.
fix Consider using koa-router or @koa/router which are actively maintained.
gotcha No ESM support; only CommonJS require() works.
fix Use `const Router = require('koa-66')` instead of `import Router from 'koa-66'`.
breaking The `mount` method expects a path and a sub-router; passing incorrect arguments may cause silent failures.
fix Ensure `router.mount('/prefix', subRouter)` is used correctly.
gotcha Plugin middleware uses `ctx.state.plugins` which may conflict with other Koa middleware.
fix Check that no other middleware sets ctx.state.plugins before using plugins.
npm install koa-66
yarn add koa-66
pnpm add koa-66

Creates a basic Koa app with a single GET route using koa-66 router.

const Koa = require('koa');
const Router = require('koa-66');
const app = new Koa();
const router = new Router();

router.get('/', async (ctx) => {
  ctx.body = 'Hello World!';
});

app.use(router.routes());
app.listen(3000);

// Visit http://localhost:3000/ => Hello World!