The fetchlet/hono/vite plugin wraps @hono/vite-build 1 to bundle Hono and
HonoX apps into a fetchlet artifact. See
examples/honox-axum
and
examples/honox-tauri
for complete setups.
Setup
// vite.config.ts
import fetchletBuild from "fetchlet/hono/vite";
import honox from "honox/vite";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [
honox(),
fetchletBuild({
entry: "./app/server.ts",
backend: "quickjs",
}),
],
});entrypoints to a module withexport default app.backend,intl, andrequirementsfollow the build options.externalis forwarded to@hono/vite-build.functionslists extra modules whose named exports become callable from Rust viaApp::call/AppHandle::call(handleis reserved) — useful for Tauri commands or CLI helpers.
Request context and bindings
| Value | Content |
|---|---|
c.env |
Rust’s fixed bindings |
c.executionCtx.waitUntil |
Registers work after the response, within Rust’s background budget |
getConnInfo(c) |
From fetchlet/hono/conninfo: client IP from the Rust request context |
getRequestContext(c) |
From fetchlet/hono/conninfo: the full Rust request context |
HonoX uses AsyncLocalStorage internally; the plugin enables
asyncContext: "serialized" automatically.
WebSockets
Use upgradeWebSocket from fetchlet/hono/websocket to handle WebSocket
routes. Configure Instances::max_held_connections on your Rust host
(WebSocket upgrades):
import { upgradeWebSocket } from "fetchlet/hono/websocket";
app.get(
"/socket",
upgradeWebSocket(() => ({
onMessage(event, ws) {
ws.send(`echo: ${String(event.data)}`);
},
})),
);Output and assets
The plugin writes build/server.js, build/fetchlet.json, and (with HonoX)
build/client/. Pass assets to pack static files into assets.flpk. Because
Hono public files are not necessarily content-hashed, configure caching
explicitly via assets: { cache: [...] }
(Asset archive).