/docs/recipes
OGP images and file export
Add build-time OGP image generation with Satori and PDF or PNG export with Cloudflare Browser Run.
Save OGP images at build time with Satori
Generate an SVG with Satori and a 1200×630 PNG with resvg from the manifest returned by compileDecks(), without Browser Rendering. Keep image generation in a Node build script so neither the Worker runtime nor hono-decks core gains these dependencies.
export default defineDecksConfig({
mountPath: "/decks",
router: {
viewer: { openGraph: true },
},
})Enabling viewer.openGraph emits absolute Open Graph and Twitter Card tags from decks.paths(slug).ogImage, which defaults to /decks/:slug/og.png. Save the PNG under Wrangler Static Assets.
Open the complete Satori + resvg recipe →
build.ogpCacheFile caches LinkCard metadata inside slides; it is unrelated to this viewer share image.
Export PDF and PNG with Browser Run
Use Cloudflare Browser Run Quick Actions through a browser binding to return the deck's print page as PDF or PNG. hono-decks calls quickAction("pdf") or quickAction("screenshot"), so this flow needs neither Puppeteer, Playwright, nor a Browser Run API token.
{
"compatibility_date": "2026-07-15",
"browser": {
"binding": "BROWSER",
"remote": true
}
}The next example assumes an earlier session or Cloudflare Access validation middleware has set deckExportAllowed.
// hono-decks.config.ts
import {
defineDecksConfig,
type DeckBrowserRunBinding,
} from "hono-decks"
type AppEnv = {
Bindings: {
BROWSER: DeckBrowserRunBinding
}
Variables: {
deckExportAllowed: boolean
}
}
export default defineDecksConfig<AppEnv>({
mountPath: "/decks",
router: {
export: {
browser: ({ c }) => c.env.BROWSER,
authorize: ({ c }) => c.get("deckExportAllowed") === true,
pdf: true,
png: true,
},
},
})| Route / API | Purpose |
|---|---|
/:slug/print | All-slide document used as Browser Run input |
/:slug/export.pdf | Download the print document as PDF |
/:slug/export.png | Download a full-page PNG of the print document |
After authorize succeeds, the export request sends the public print URL to the binding and returns its file as an attachment. Viewer export controls are shown only on requests that pass the same authorization.
Store bearer tokens as Wrangler secrets rather than plain vars values.