Configuration

Keep build settings in hono-decks.config.ts and runtime options in createDecks().

CLI init keeps build settings in decks/config.ts and runtime settings in decks/index.ts, and records the config path in package.json. Vite framework init retains hono-decks.config.ts and its app-owned facade. Explicit config paths and existing layouts remain supported.

Know which file owns each setting

hono-decks init creates hono-decks.config.ts, decks/index.ts, and a sample deck, and adds the generated directory to .gitignore. The config file is build-only: the CLI and the Vite plugin read it, and the Worker never imports it.

hono-decks.config.ts
Build settings: the public mountPath, deck root, and output directory.
decks/index.ts
Runtime options passed to createDecks(): viewer, presenter, export, source, and more.
.hono-decks/
Compiler-owned modules. Rebuilt on every dev, build, and typecheck run; not committed.
package.json
Runs the existing Vite or Wrangler development command.
hono-decks.config.ts
// hono-decks.config.ts
import { defineDecksConfig } from "hono-decks"

export default defineDecksConfig({
  mountPath: "/decks",
  build: { root: "decks", outDir: ".hono-decks" },
})

With Vite (init --framework hono, honox, or void), modules stay in memory and src/decks.ts imports createDecks from virtual:hono-decks. build.outDir is not needed.

/// <reference types="hono-decks/vite-env" />
import { createDecks } from "virtual:hono-decks"

export const decks = createDecks()

Connect the compiler to the dev lifecycle

Add honoDecks() to Vite, or register hono-decks compile as a Wrangler custom build. Either way, your existing dev command compiles decks; no separate script is needed.

vite.config.ts
import { honoDecks } from "hono-decks/vite"
import { defineConfig } from "vite"

export default defineConfig({
  plugins: [honoDecks()],
})
wrangler.jsonc
{
  "build": {
    "command": "hono-decks compile",
    "watch_dir": ["decks"]
  }
}

Set LinkCard cache at build.ogpCacheFile. Use --refresh-ogp only for an intentional refresh.

Open the OGP and file-export recipes →

Configure values that change per request

Pass runtime options to createDecks(). Its type parameter type-checks Hono Bindings and Variables in every resolver. When dev is omitted, hono-decks reads the NODE_ENV set by Vite and Wrangler. With their standard settings, vite and wrangler dev use development mode, while production builds and wrangler deploy use production mode. An explicit boolean or resolver takes precedence. If the environment cannot be detected, hono-decks defaults safely to production mode.

TypeScript
// src/decks.ts
import { createDecks } from "#decks"

type AppEnv = {
  Bindings: {
    PRESENTER_ENABLED?: string
  }
  Variables: {
    language: string
  }
}

export const decks = createDecks<AppEnv>({
  document: {
    lang: ({ c }) => c.get("language"),
  },
  presenter: {
    enabled: ({ c, dev }) => dev || c.env.PRESENTER_ENABLED === "true",
  },
})

The c.get("language") example assumes Hono's languageDetector() is registered first; see document policy and security. For a single-language app, use a fixed value such as lang: "en".

Make precedence explicit

Generated defaults, app config from createDecks(), and decks.router(overrides) are applied in order. One merge rule applies everywhere: objects merge recursively, arrays concatenate, and any other value — including false and functions — replaces the earlier one.

TypeScript
// src/index.ts
app.route(
  decks.mountPath,
  decks.router({ viewer: { controls: { hidden: ["print"] } } }),
)

Choose the right configuration boundary

mountPath
Build config. The public path baked into asset URLs and decks.mountPath.
build
Build config. Deck root, output directory, Markdown adapter, and LinkCard cache.
source
createDecks() option. Wraps the generated source with R2, caching, or custom asset loading.
document, pages, viewer, presenter, embed, export
createDecks() options for each route and feature.

Open the defineDecksConfig API →

UI messages

The resolved document.lang selects Japanese for ja and tags such as ja-JP, and English otherwise. It defaults to ja. Override messages per locale with createDecks({ messages: { ja: { previous: "戻る" }, en: { previous: "Back" } } }). viewer.controls.labels takes precedence for those controls. Templates use named placeholders: slidePosition and progressText use {current} and {total}, and slideCount / slideCountOne use {count}.

Built with HonoX and honoxpress.