/api

API reference

Choose the correct package entry first, then find the function or type for the task at hand.

Most applications start with the generated createDecks(config)

The src/decks.ts facade created in the getting-started guide is the boundary between generated modules and public APIs. You do not need to compose low-level APIs just to render a deck.

hono-decks
Worker-safe runtime APIs for Hono applications. This is the normal entry.
hono-decks/advanced
Low-level APIs for custom sources, routers, and renderers.
hono-decks/node
Filesystem and compiler APIs for builds only. Never import this entry in Worker runtime code.
hono-decks/client
Island hydration. Generated client code normally uses it for you.

Start with the getting-started guide →

Runtime entry

Import these APIs from hono-decks in Hono and Worker code. Start with the generated facade, and use a direct API only when the facade does not cover your use case.

defineDecksConfig

hono-decks

Defines the shared CLI and runtime configuration.

Use it whenKeeping mount path, build input, and runtime policy in one file.

Import + signature
import { defineDecksConfig } from "hono-decks"

defineDecksConfig(config: DecksConfig): DecksConfig

ConfiguredDecks

hono-decks

The application kit returned by generated createDecks(config).

Use it whenUsing routes, custom pages, and URLs from one config.

Import + signature
import type { ConfiguredDecks } from "hono-decks"

interface ConfiguredDecks { mountPath; source; router(); context(); paths(slug) }

createDeckPaths

hono-decks

Creates every public URL for one deck.

Use it whenCreating a path map outside a configured kit.

Import + signature
import { createDeckPaths } from "hono-decks"

createDeckPaths(mountPath, slug): DeckPaths

decksRouter

hono-decks/advanced

Builds a low-level router from a custom DeckSource.

Use it whenBuilding a custom pipeline without generated createDecks(config).

Import + signature
import { decksRouter } from "hono-decks/advanced"

decksRouter(options: DecksRouterOptions): Hono

Rendering and extension

Decompose and extend the default UI or replace its asset source.

createDeckViewerParts

hono-decks/advanced

Returns viewer parts independently.

Use it whenComposing a fully custom viewer layout.

Import + signature
import { createDeckViewerParts } from "hono-decks/advanced"

createDeckViewerParts(input): Promise<DeckViewerParts>

createDeckViewerEmbed

hono-decks

Creates an embedded viewer with scoped CSS and runtime behavior.

Use it whenEmbedding a viewer directly in a custom page. Use the router embed option for an external iframe route.

Import + signature
import { createDeckViewerEmbed } from "hono-decks"

createDeckViewerEmbed(input: DeckViewerEmbedOptions): Promise<DeckViewerEmbed>

withR2Assets

hono-decks

Wraps generated assets with an R2-backed source.

Use it whenMoving generated asset delivery to Cloudflare R2 without changing relative MDX paths.

Import + signature
import { withR2Assets } from "hono-decks"

withR2Assets(source: DeckSource, options: R2AssetSourceOptions): DeckSource

defineSlideComponents

hono-decks

Creates a typed registry for built-in and application components.

Use it whenRegistering shared components across decks or replacing built-ins. Keep deck-specific components under components/.

Import + signature
import { defineSlideComponents } from "hono-decks"

defineSlideComponents(input: Record<string, SlideComponentInput>): SlideComponentRegistry

renderCompiledDeckAsync

hono-decks/advanced

Renders a compiled deck directly.

Use it whenBuilding a low-level custom rendering pipeline.

Import + signature
import { renderCompiledDeckAsync } from "hono-decks/advanced"

renderCompiledDeckAsync(deck: CompiledDeck, input?): Promise<string>

Configuration and model types

Types for public surfaces, shared HTML policy, and custom DeckSource implementations.

DeckViewerOpenGraphOptions

hono-decks

Configures the viewer's Open Graph and Twitter Card image from the canonical path or a resolver.

Use it whenConnecting a build-generated or CDN-hosted image to viewer social metadata.

Import + signature
import type { DeckViewerOpenGraphOptions } from "hono-decks"

interface DeckViewerOpenGraphOptions { imagePath?: string | (({ deck, paths }) => MaybePromise<string | undefined>) }

DecksRouterPagesOptions

hono-decks

Configures index rendering and HTML route surfaces per request.

Use it whenDisabling unused public surfaces or gating them by authentication and environment.

Import + signature
import type { DecksRouterPagesOptions } from "hono-decks"

interface DecksRouterPagesOptions { index?; viewer?; render?; print?; presentation?; presenter? }

DeckRouteSurfaceInput

hono-decks

Passes Hono context, deck, mount path, and dev state into route gates.

Use it whenTyping a reusable pages resolver defined outside the router configuration.

Import + signature
import type { DeckRouteSurfaceInput } from "hono-decks"

interface DeckRouteSurfaceInput { c; surface; mountPath; dev; deck?; slug? }

DeckDocumentOptions

hono-decks

Defines language, nonce, head content, and per-surface overrides.

Use it whenApplying lang, CSP nonce, or head elements to every generated HTML surface.

Import + signature
import type { DeckDocumentOptions } from "hono-decks"

interface DeckDocumentOptions extends DeckDocumentPageOptions { surfaces? }

DeckExternalEmbedOptions

hono-decks

Opts into an external iframe document route with explicit policy.

Use it whenEmbedding decks on another origin with explicit parent origins and viewer settings.

Import + signature
import type { DeckExternalEmbedOptions } from "hono-decks"

interface DeckExternalEmbedOptions { frameAncestors?; document?; viewer? }

DeckSource

hono-decks

Separates runtime deck and asset access from storage implementations.

Use it whenLoading decks outside the generated manifest or implementing a custom storage source.

Import + signature
import type { DeckSource } from "hono-decks"

interface DeckSource { listDecks(c); getCompiledDeck(c, slug); getAsset?(c, slug, path) }

Node and client entries

Filesystem/compiler APIs live in the Node entry; hydration lives in the client entry.

compileDecks

hono-decks/node

Compiles filesystem decks and emits the manifest and generated modules.

Use it whenCalling the compiler from a custom build script or plugin. Most projects use the hono-decks compile CLI.

Import + signature
import { compileDecks } from "hono-decks/node"

compileDecks(input: CompileDecksInput): Promise<DeckManifest>

createLocalDeckIO

hono-decks/node

Keeps dev-only raw deck I/O separate from the runtime DeckSource.

Use it whenBuilding custom deck editing or preview tooling. It does not belong in ordinary runtime code.

Import + signature
import { createLocalDeckIO } from "hono-decks/node"

createLocalDeckIO(input: CreateLocalDeckIOInput): LocalDeckIO

hydrateSlideIslands

hono-decks/client

Hydrates interactive islands from the generated client entry.

Use it whenBuilding a custom client delivery pipeline. The generated client entry normally calls it for you.

Import + signature
import { hydrateSlideIslands } from "hono-decks/client"

hydrateSlideIslands(input: HydrateSlideIslandsInput): void