Skip to main content

@oak/oak@17.1.3
Built and signed on GitHub Actions

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

This package works with Cloudflare Workers, Node.js, Deno, Bun
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
JSR Score
100%
Published
4 weeks ago (17.1.3)

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

Add Package

deno add jsr:@oak/oak

Import symbol

import * as oak from "@oak/oak";

---- OR ----

Import directly with a jsr specifier

import * as oak from "jsr:@oak/oak";

Add Package

npx jsr add @oak/oak

Import symbol

import * as oak from "@oak/oak";

Add Package

yarn dlx jsr add @oak/oak

Import symbol

import * as oak from "@oak/oak";

Add Package

pnpm dlx jsr add @oak/oak

Import symbol

import * as oak from "@oak/oak";

Add Package

bunx jsr add @oak/oak

Import symbol

import * as oak from "@oak/oak";