Server Adapters
mini() is MiniFW's Bun-only convenience server. It starts Bun.serve(), registers pages and partials, resolves layouts, builds documents, and loads configured global assets.
The render primitives receive Bun's Bun.BunRequest, so use MiniFW with Bun servers. A different runtime can still use fragment() for context-free markup.
Bun.serve()
Use page.render(context) inside a native Bun route. Bun provides matched route parameters on request.params; its route request satisfies MiniContext's request field directly.
import { page } from "@calvinbonner/minifw/core";
import { html, isHtmx } from "@calvinbonner/minifw/helpers";
const product = page(({ params }) => html`<h1>Product ${params["name"]}</h1>`);
Bun.serve({
routes: {
"/products/:name": async (request) => {
const context = {
request,
url: new URL(request.url),
route: "/products/:name",
params: request.params ?? {},
isHtmx: isHtmx(request),
};
const content = await product.render(context);
return new Response(content, {
headers: { "Content-Type": "text/html; charset=utf-8" },
});
},
},
});
Choosing An Approach
Use mini() for a Bun application that wants MiniFW to own the full document, routing, layouts, global styles/scripts, caching, redirects, and error mapping.
Native Routes
Use a native route entry when an existing Bun application already owns a route's response handling. MiniFW passes native Bun entries directly to Bun.serve().
The Bun.serve() example is a runnable reference implementation.