Skip to main content

@oak/oak@16.0.0

A middleware framework for handling HTTP with Deno, Node.js, Bun and Cloudflare Workers 🐿️🦕🥟⚙️

Works with
This package works with Bun
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
JSR Score
100%
Published
5 days ago
deno add @oak/oak
import * as mod from "@oak/oak";
npx jsr add @oak/oak
import * as mod from "@oak/oak";
yarn dlx jsr add @oak/oak
import * as mod from "@oak/oak";
pnpm dlx jsr add @oak/oak
import * as mod from "@oak/oak";
bunx jsr add @oak/oak
import * as mod from "@oak/oak";

A middleware framework for handling HTTP with Deno CLI, Deno Deploy, Cloudflare Workers, Node.js, and Bun.

oak is inspired by koa.

Example server

A minimal router server which responds with content on /.

Deno CLI and Deno Deploy

import { Application } from "jsr:@oak/oak/application";
import { Router } from "jsr:@oak/oak/router";

const router = new Router();
router.get("/", (ctx) => {
  ctx.response.body = `<!DOCTYPE html>
    <html>
      <head><title>Hello oak!</title><head>
      <body>
        <h1>Hello oak!</h1>
      </body>
    </html>
  `;
});

const app = new Application();
app.use(router.routes());
app.use(router.allowedMethods());

app.listen({ port: 8080 });

Node.js and Bun

You will have to install the package and then:

import { Application } from "@oak/oak/application";
import { Router } from "@oak/oak/router";

const router = new Router();
router.get("/", (ctx) => {
  ctx.response.body = `<!DOCTYPE html>
    <html>
      <head><title>Hello oak!</title><head>
      <body>
        <h1>Hello oak!</h1>
      </body>
    </html>
  `;
});

const app = new Application();
app.use(router.routes());
app.use(router.allowedMethods());

app.listen({ port: 8080 });

Cloudflare Workers

You will have to install the package and then:

import { Application } from "@oak/oak/application";
import { Router } from "@oak/oak/router";

const router = new Router();
router.get("/", (ctx) => {
  ctx.response.body = `<!DOCTYPE html>
    <html>
      <head><title>Hello oak!</title><head>
      <body>
        <h1>Hello oak!</h1>
      </body>
    </html>
  `;
});

const app = new Application();
app.use(router.routes());
app.use(router.allowedMethods());

export default { fetch: app.fetch };
Built and signed on
GitHub Actions
View transparency log