/docs/configuration
Configuration
Manage compilation and runtime behavior in one shared hono-decks.config.ts file.
Know which file owns each setting
hono-decks init creates the required hono-decks.config.ts and src/decks.ts. Build input, public paths, and runtime policy live in this one config.
package.json- Runs the existing Vite or Wrangler development command.
hono-decks.config.ts- Required configuration shared by the CLI and runtime.
decks.ts- A stable facade that combines the generated source, config, and call-site overrides.
generated/- Compiler-owned manifest and slide modules.
Connect the compiler to the dev lifecycle
Add honoDecks() to Vite, or register hono-decks compile as a Wrangler custom build. The shared config supplies build.root, build.outDir, and mountPath.
import { honoDecks } from "hono-decks/vite"
import { defineConfig } from "vite"
export default defineConfig({
plugins: [honoDecks()],
}){
"scripts": {
"decks:compile": "hono-decks compile",
"dev": "vite",
"build": "vite build"
}
}Set LinkCard cache at build.ogpCacheFile. Use --refresh-ogp only for an intentional refresh.
Configure values that change per request
Use defineDecksConfig() to type-check Hono Bindings and Variables as part of the config. 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.
// hono-decks.config.ts
import { defineDecksConfig } from "hono-decks"
type AppEnv = {
Bindings: {
PRESENTER_ENABLED?: string
}
Variables: {
language: string
}
}
export default defineDecksConfig<AppEnv>({
mountPath: "/decks",
build: { root: "decks", outDir: "src/generated" },
router: {
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 in the facade
Generated defaults, app config, and decks.router(overrides) are applied in order; the configured kit merges nested options.
// src/decks.ts
import config from "../hono-decks.config"
import { createDecks } from "./generated/decks"
export const decks = createDecks(config)Choose the right configuration boundary
mountPath- The public path shared by the facade and app.
source(source)- Wraps the generated source with R2, caching, or custom asset loading.
router- Runtime options for document, pages, viewer, presenter, embed, export, and more.