Hono helpers. The context is typed as any, so this module does not depend on Hono. It also re-exports the web helpers (htmlResponse, jsonResponse, sseEvent). Because the engine reads templates from disk, run Hono on Node, Bun or Deno.
any
htmlResponse
jsonResponse
sseEvent
import { Hono } from 'hono';import { stream } from 'hono/streaming';import { Fragment, Page, Setup, escapeHtml } from '@anzaui/engine';import { html, json, sseEvent } from '@anzaui/engine/adapters/hono';const engine = await new Setup({ root: './templates' }).run();const app = new Hono();app.get('/', async (c) => html(c, await new Page('/', { title: 'Anza + Hono' }).run(engine)));app.get('/card/:id', async (c) => { const envelope = await new Fragment('feed/card.html', 'feed', { id: escapeHtml(c.req.param('id')), // values are not escaped unless `escape: true` }).run(engine); return json(c, envelope);});app.get('/feed/stream', (c) => { c.header('Content-Type', 'text/event-stream'); return stream(c, async (s) => { await s.write(sseEvent(await new Fragment('feed/card.html', 'feed', { title: 'Push' }).run(engine))); });});export default app; Copy
import { Hono } from 'hono';import { stream } from 'hono/streaming';import { Fragment, Page, Setup, escapeHtml } from '@anzaui/engine';import { html, json, sseEvent } from '@anzaui/engine/adapters/hono';const engine = await new Setup({ root: './templates' }).run();const app = new Hono();app.get('/', async (c) => html(c, await new Page('/', { title: 'Anza + Hono' }).run(engine)));app.get('/card/:id', async (c) => { const envelope = await new Fragment('feed/card.html', 'feed', { id: escapeHtml(c.req.param('id')), // values are not escaped unless `escape: true` }).run(engine); return json(c, envelope);});app.get('/feed/stream', (c) => { c.header('Content-Type', 'text/event-stream'); return stream(c, async (s) => { await s.write(sseEvent(await new Fragment('feed/card.html', 'feed', { title: 'Push' }).run(engine))); });});export default app;
Hono helpers. The context is typed as
any, so this module does not depend on Hono. It also re-exports the web helpers (htmlResponse,jsonResponse,sseEvent). Because the engine reads templates from disk, run Hono on Node, Bun or Deno.Example