Skip to main content

Other Runtime

Support Bun, Node, CF-Workers, etc.

For Nodejs, requires v18.0.0 or higher.

Install

npm i nhttp-land

// or

yarn add nhttp-land
import nhttp from "nhttp-land";

Usage (Bun / Node)

import nhttp from "nhttp-land";

const app = nhttp();

app.get("/", () => "hello, world");

app.listen(8000, () => {
console.log("> Running on port 8000");
});

// if cfw or other runtime, just invoke app.handle
// export default { fetch: app.handle };

tsconfig

{
"compilerOptions": {
"types": ["bun-types"],
"moduleResolution": "nodenext",
"target": "ES5",
"lib": [
"DOM",
"DOM.Iterable",
"ESNext"
]
}
}