Skip to content

Hono

Use miki-template with Hono (ESM-first framework) by calling asyncRender() in your handlers.

Setup

import { Hono } from 'hono';
import miki from 'miki-template';

const app = new Hono();

app.get('/', async (c) => {
  const html = await miki.asyncRender(
    'index',
    { user: c.get('user') },
    { views: './views' }
  );
  return c.html(html);
});

export default app;
const { Hono } = require('hono');
const miki = require('miki-template');

const app = new Hono();

app.get('/', async (c) => {
  const html = await miki.asyncRender(
    'index',
    { user: c.get('user') },
    { views: './views' }
  );
  return c.html(html);
});

module.exports = app;

Partial Rendering

app.get('/partials/:name', async (c) => {
  const html = await miki.asyncRender(
    `home#${c.req.param('name')}`,
    { user: c.get('user') },
    { views: './views' }
  );
  return c.html(html);
});
app.get('/partials/:name', async (c) => {
  const html = await miki.asyncRender(
    `home#${c.req.param('name')}`,
    { user: c.get('user') },
    { views: './views' }
  );
  return c.html(html);
});

Next Steps

  • Integrations Overview
  • [API Reference: asyncRender param($m) $m.Value -replace '([a-z][a-z0-9-]+).md , '../.md' -replace '([a-z][a-z0-9-]+) , '../.md'