Hono

Set up Comark Content in a Hono server.

Hono hands you the raw web-standard Request as c.req.raw, so content.handler() mounts as a one-line wildcard route — on Node, Bun, Deno, Cloudflare Workers, or anywhere else Hono runs.

Install the packages

pnpm add comark-content

Create the Content instance

content.ts
import { comarkContent } from 'comark-content'
import fs from 'comark-content/sources/fs'

export const content = comarkContent({
  source: fs('./content'),
})

Mount the handler

server.ts
import { Hono } from 'hono'
import { content } from './content'

const app = new Hono()

app.all('/api/content/*', (c) => content.handler(c.req.raw))

export default app

That's the whole data surface: GET /api/content/get/<path>, /api/content/list/..., /api/content/navigation, plus any custom serve handlers you register.

Read content from other routes

Routes on the same server skip HTTP and call the instance directly:

server.ts
app.get('/pages/:slug', async (c) => {
  const page = await content.get(`/${c.req.param('slug')}`)
  if (!page) return c.notFound()

  return c.json(page)
})

Consume it from a front-end

Any browser app talks to the mounted handler through the client, pass baseURL if the Hono server runs on another origin:

content-client.ts
import { createContentClient } from 'comark-content/client'

export const contentClient = createContentClient({
  baseURL: 'https://api.example.com',
})

Going further

Client & handler

How the handler/client pair works, and how to extend it with plugin pairs.

Caching

Persist parsed bodies with any unstorage driver to speed up reads.