Get started

Compile an MDX deck, mount the generated router in an existing Hono application, and verify it in your browser.

Upgrading from 1.x? Follow the 2.0 migration guide for configuration changes, renamed APIs, and removed features.

Start with a working app

You need npm, pnpm, Yarn, or Bun and a running Hono, HonoX, or Void app. Framework-specific setup normally serves its sample at /decks/welcome; the generic CLI/file workflow uses /decks/welcome.

Choose the setup for your application

For an existing Hono + Vite or HonoX application, install hono-decks and choose its integration. For Void, use the Void command; --install installs missing compatible Markdown dependencies using the app's package manager. Review the CLI output if it reports an unsupported configuration or an existing integration.

npm install hono-decks
# Choose one:
npx hono-decks init --framework hono
npx hono-decks init --framework honox
npx hono-decks init --framework void --install
npm run dev

Each integration preserves existing scripts and uses virtual:hono-decks; dev and build compile decks in memory. Open the sample URL printed by init, normally /decks/welcome. Hono and HonoX start with MDX; Void creates a Markdown sample with an interactive island. For supported versions, optional peer dependencies, and setup limitations, see the package README.

For a Void setup using MDX, see the Void example. This example does not require a Hono Markdown adapter.

Framework-specific setup ends here. The steps below describe the separate generic CLI/file workflow, useful for manual integration and Wrangler. Its init defaults to /decks and compile writes generated files to disk.

Install the package and create the config

The example uses npm. init creates the build-only decks/config.ts, the app-owned decks/index.ts for runtime options, and a sample deck, and adds .hono-decks/ to .gitignore. It refuses to overwrite existing files.

Terminal
npm install hono-decks
npx hono-decks init
Package managerInstallRun the CLI
npmnpm install hono-decksnpx hono-decks <command>
pnpmpnpm add hono-deckspnpm exec hono-decks <command>
Yarnyarn add hono-decksyarn hono-decks <command>
Bunbun add hono-decksbunx hono-decks <command>

Replace <command> with init or compile, and use the same package manager for the remaining examples.

Create and compile the first deck

Create decks/welcome/deck.mdx. The first frontmatter block describes the whole deck; the next --- starts slide one.

decks/welcome/deck.mdx
---
title: Welcome
description: My first hono-decks presentation
---

---
layout: cover
---

# Welcome

This deck is served from my Hono app.

---

## Next slide

- Write slides in MDX
- Serve them with Hono

Compile the MDX into Hono JSX modules. A successful run creates .hono-decks/.

Terminal
npx hono-decks compile

Generated files

  • decks/config.ts
  • decks
    • index.ts
    • welcome
      • deck.mdx

decks/config.ts holds build settings that only the CLI reads. Edit the app-owned decks/index.ts and deck.mdx as needed. Never edit or commit .hono-decks/; each compile replaces it.

Mount the generated router in Hono

Add the generated router to the existing Hono app.

TypeScript
// src/index.ts
import { Hono } from "hono"
import { decks } from "../decks"

const app = new Hono()
app.route(decks.mountPath, decks.router())

export default app

decks.mountPath is compiled from the config, keeping compile-time assets and runtime routes on the same public path. Mounting the router elsewhere fails with an explicit error.

Use your existing development command

CLI init registers the package-private #decks import and prefixes existing dev/build/typecheck/test/deploy scripts with compilation. Do not edit or commit the internal .hono-decks/ cache.

For cf projects, keep the custom compilation hook in wrangler.config.ts so deck edits rebuild during cf dev. See the Minimal example. For an existing Wrangler project, follow Cloudflare’s migration guide before using cf. Vite apps use virtual:hono-decks and do not write this cache.

package.json
{
  "imports": {
    "#decks": "./.hono-decks/decks.ts"
  },
  "scripts": {
    "dev": "hono-decks compile && cf dev",
    "build": "hono-decks compile && cf build"
  }
}

Verify the generic workflow in the browser

Terminal
npm run dev

Open /decks/welcome on the local URL printed by the dev server. The setup works when the Welcome slide appears and the controls or arrow keys move to slide two.

Troubleshooting

Missing .hono-decks/decks.ts
Run npx hono-decks compile again and check build.root and build.outDir in the config.
/decks returns 404
Mount decks.router() at decks.mountPath.
Node modules enter the Worker bundle
Import runtime APIs from hono-decks. Keep hono-decks/node in build scripts only.

Choose the next step

Continue with authoring slides. Open configuration or routes and UI only when you need environment bindings or different public surfaces.

Built with HonoX and honoxpress.