An Simple web-framework for Deno and Friends.
MIT License
json / urlencoded / multipart / raw
).// Deno
deno add @nhttp/nhttp
// npm
npx jsr add @nhttp/nhttp
// Yarn
yarn dlx jsr add @nhttp/nhttp
// pnpm
pnpm dlx jsr add @nhttp/nhttp
// Bun
bunx jsr add @nhttp/nhttp
import nhttp from "https://deno.land/x/nhttp/mod.ts";
Create file app.ts
and copy-paste this code.
import nhttp from "@nhttp/nhttp";
const app = nhttp();
app.get("/", () => {
return "Hello, World";
});
app.get("/cat", () => {
return { name: "cat" };
});
app.listen(8000);
deno run -A app.ts
Create file app.tsx
and copy-paste this code.
import nhttp from "@nhttp/nhttp";
import { htmx, renderToHtml } from "@nhttp/nhttp/jsx";
const app = nhttp();
app.engine(renderToHtml);
app.use(htmx());
app.get("/", () => {
return (
<button hx-post="/clicked" hx-swap="outerHTML">
Click Me
</button>
);
});
app.post("/clicked", () => {
return <span>It's Me</span>;
});
app.listen(8000);
deno.json / tsconfig.json
{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "@nhttp/nhttp/jsx"
}
}
more docs => https://nhttp.deno.dev
Like std-libs
for NHttp.
// JSR
import {...} from "@nhttp/nhttp/my-libs";
// deno.land
import {...} from "https://deno.land/x/nhttp/lib/my-libs.ts";
import nhttp from "@nhttp/nhttp";
import serveStatic from "@nhttp/nhttp/serve-static";
const app = nhttp();
app.use(serveStatic("./my_folder"));
// with prefix
app.use(serveStatic("./my_folder", { prefix: "/assets" }));
// or
// app.use("/assets", serveStatic("./my_folder"));
// with URL
app.use(serveStatic(new URL("./my_folder", import.meta.url)));
deno run -Ar npm:create-nhttp
npm create nhttp@latest