Skip to content
slidepig.

Documentation

Build & publish

Create a site of decks, configure hosting, and share content across a workspace.

On this page

A folder of slidepig decks becomes a site: a home page listing them, one prerendered page per deck, build-time validation, and a Cloudflare Worker to serve it all.

Try the live examples or follow the getting started guide. Site tooling requires Node.js 22.12+; deck components require React 19+.

The quickest start is npx slidepig@latest create my-decks --skill. This copies a working example and the agent skill from the package. Omit --skill if you do not need agent instructions. Use --workspace for a site app plus shared deck package in a pnpm workspace; see Existing monorepos. By hand, it is three files, plus the build tools as dev dependencies:

npm i slidepig react react-dom
npm i -D vite sharp html-validate linkedom wrangler
// src/site.ts
import { defineSite } from "slidepig/site";
import media from "./generated/media-manifest.json";

export default defineSite({
  title: "Presentations",
  description: "Decks that read like documents and present like slides.",
  // Every file in decks/ is a deck, served at /<file name>.
  decks: import.meta.glob("./decks/*.{ts,tsx}", {
    eager: true,
    import: "default",
  }),
  media,
});
// vite.config.ts
import { defineConfig } from "vite";
import { slidepigSite } from "slidepig/site/vite";

export default defineConfig({ plugins: [slidepigSite()] });
// worker/index.ts
export { default } from "slidepig/site/worker";

What the plugin does

  • vite serves server-rendered pages that hydrate, like production.
  • vite build builds the client, builds the renderer, prerenders every route into dist/ and validates the result. The build fails when:
    • a deck has validateDeck errors (warnings are printed),
    • a page is invalid HTML (html-validate),
    • a page lacks a language, title, description or a single <h1>,
    • an in-page #link points nowhere,
    • any local URL (scripts, styles, images, srcset candidates, preload hints, background URLs) is missing from dist/,
    • a deck page is missing one of its slides or the client script,
    • the home page does not link to every deck.

The default home page ships no JavaScript. A custom home can opt into its own module scripts with home.scripts. Deck pages load one script that hydrates the prerendered markup.

defineSite options

Option Purpose
title site title, also the home page heading
description home page description and meta description
decks { slugOrPath: deck }, usually from import.meta.glob
media the slidepig assets manifest, for optimized images
home { title, description, render, stylesheets, scripts }, or false for one deck served at /
pages Supporting static pages keyed by slug, each with { title, description, render, stylesheets, scripts }
trailingSlash true: decks at /<slug>/ instead of /<slug> (the other form redirects)
list false: no page lists the decks (/ is a 404, the 404 names none)
deckProps props for every <Deck>: tuner, labels, sidebar…
robots e.g. "noindex, nofollow" for private pitches
origin absolute origin, enables canonical and og:url tags
favicon an emoji or a URL
lang home page language; decks declare their own

Each deck's lang also selects its built-in control labels: French for fr and regional variants such as fr-CA, English otherwise. Explicit deckProps.labels still overrides those defaults. No per-deck propsFor patch is needed for a bilingual site.

Private pitches, each reached only by its own link:

export default defineSite({
  title: "Decks",
  list: false,
  robots: "noindex, nofollow",
  decks: { acme, globex }, // served at /acme and /globex
});

With list: false, opening the bare domain returns 404 intentionally. Share the individual deck URLs; no page lists them. Use home: false instead when the entire site is one deck that should open at /.

A single private pitch on its own subdomain:

export default defineSite({
  title: "Acme × Example",
  home: false,
  robots: "noindex, nofollow",
  decks: { pitch },
});

A custom home page

The default home is a static deck listing. A site can supply its own React markup and home-only styles without changing deck pages or adding JavaScript to the homepage:

import { DeckIndex } from "slidepig";

// Inside defineSite({ ... })
home: {
  title: "Our presentations",
  stylesheets: ["/home.css"], // public/home.css; scope classes to your page
  render: (props) => (
    <DeckIndex {...props}>
      <footer>Something worth sharing.</footer>
    </DeckIndex>
  ),
},

scripts: ["/home.js"] optionally loads a home-only module from public/, for enhancements such as a clipboard button. These scripts are validated during builds and are not added to deck or error pages.

render receives DeckIndexProps: title, description, deck entries, and the image resolver. Return a complete page body with one <main> and one <h1>. Keep a link to every deck: build validation checks them. The 404 page keeps the default listing, and list: false or home: false bypasses the custom homepage. Put stylesheet files in public/; they are validated during builds.

Supporting pages

Use pages for an about page, offer, or contact page alongside the decks:

pages: {
  about: {
    title: "About our presentations",
    description: "Meet the team behind these decks.",
    stylesheets: ["/about.css"],
    render: () => <main><h1>About our presentations</h1></main>,
  },
},

This creates /about (or /about/ with trailingSlash). Pages use the same prerendering, canonical URLs, language, robots policy, and build validation as the rest of the site. Each renderer receives DeckIndexProps; list: false passes an empty deck list. Page-specific styles and optional module scripts load only on that page. The deck client script is not loaded automatically. Page slugs must use lowercase letters, digits, and dashes, and cannot reuse a deck slug or the reserved names index and 404. Return one <main> and one <h1>, and supply a description for build validation.

The Worker

Serves dist/ through the static assets binding and sets the cache policy: content-hashed files under /assets/ and /_media/ are immutable for a year, and HTML is max-age=0, must-revalidate, so a deploy shows up at once while unchanged pages cost a 304.

Every page gets two validators. A weak ETag is hashed from the page, since production asset bindings send HTML without one. With the version_metadata binding, a Last-Modified comes from the deploy time. Cloudflare drops ETags from HTML when zone features (such as Email Obfuscation) rewrite pages, but it keeps Last-Modified, so revalidation keeps working either way. createSiteWorker({ headers }) adds headers of your own.

// wrangler.jsonc
{
  "name": "my-presentations",
  "main": "worker/index.ts",
  "compatibility_date": "2025-09-01",
  "version_metadata": { "binding": "CF_VERSION_METADATA" },
  "assets": {
    "directory": "./dist",
    "binding": "ASSETS",
    "html_handling": "auto-trailing-slash",
    "not_found_handling": "404-page",
    "run_worker_first": true,
  },
}

The starter includes this Worker and Wrangler configuration. Choose your own Worker name; the example intentionally omits account_id. Log into the account you intend to deploy to, then build and preview before deploying:

npx wrangler login
npx wrangler whoami
npm run typecheck
npm run build
npm run preview
# After checking the preview, stop it and deploy the built dist/:
npm run deploy

For a custom domain in your Cloudflare account, add a route to your own wrangler.jsonc, replacing the example hostname:

"routes": [{ "pattern": "decks.example.com", "custom_domain": true }]

Set origin: "https://decks.example.com" in defineSite for canonical and link-preview URLs. The site app owns deployment; a deck package needs no Worker, domain, or account configuration. Ignore dist/, dist-server/, .wrangler/, and generated public/_media/ files, and commit the source images and media manifest.

New decks

npx slidepig new q3-review --title "Q3 review"

writes src/decks/q3-review.ts with a starter outline. With import.meta.glob there is nothing to register: the next build serves it at /q3-review.

Existing monorepos

The single-folder starter also works inside a workspace. Split content into a package when several apps need the decks, or when a collection shares slides, styling, and media. Create that split in a new directory:

npx slidepig@latest create my-presentations --workspace --skill
cd my-presentations
pnpm install
pnpm --dir apps/decks dev

Or run the creator at an existing pnpm workspace root:

npx slidepig@latest create . --workspace --skill

The workspace scaffold writes apps/decks and packages/decks from the tested public reference. It refuses existing target directories rather than overwriting them. --skill also refuses an existing destination skill; omit that flag to preserve one already installed. In an existing workspace, it does not change the root manifest, workspace configuration, or lockfile and does not install dependencies. Ensure the workspace includes both new paths, reuse supported host tool versions, then install with the host's package manager. The command warns about Vite, TypeScript, or Wrangler version differences; it does not upgrade them. Review lockfile changes after installing.

For a new workspace the creator supplies the root files too. Build, preview, and deploy from the owning app, for example pnpm --dir apps/decks build followed by pnpm --dir apps/decks preview. Set the Worker name and optional domain in that app's Wrangler config as described above.

The public reference has two small parts:

  • apps/workspace-site: site configuration, Vite, and the Cloudflare Worker.
  • packages/example-decks: two audience variants, shared slides and CSS, original images, assets configuration, and the committed media manifest.

In the slidepig checkout, run:

pnpm install
pnpm build:lib
pnpm --filter slidepig-example-workspace-site dev
pnpm --filter @slidepig-example/decks typecheck
pnpm --filter slidepig-example-workspace-site typecheck
pnpm --filter slidepig-example-workspace-site build
pnpm --filter slidepig-example-workspace-site preview

To use the example in your own workspace, copy both directories, rename the packages, and update the site app's dependency and imports together. Include the directories in your workspace configuration. Replace the example's slidepig: "workspace:*" dependencies with the published slidepig version you use; keep workspace:* for the app's local deck-package dependency. Reuse your workspace's supported tool versions: slidepig supports Vite 7 and 8, and this example uses TypeScript 5.9 and Wrangler 4. Check the actual package peer ranges when upgrading. There is no need to upgrade the host app's tools just to copy an example, and installing a workspace app can still change shared lockfile resolutions.

A single deck registry

The content package exports one registry. Its keys become the site URLs:

// packages/example-decks/src/index.ts
import partnerPitch from "./decks/partner-pitch";
import teamUpdate from "./decks/team-update";

export const decks = {
  "partner-pitch": partnerPitch,
  "team-update": teamUpdate,
};

The app imports the registry, styles, and manifest:

// apps/workspace-site/src/site.ts
import { defineSite } from "slidepig/site";
import { decks } from "@slidepig-example/decks";
import media from "@slidepig-example/decks/media-manifest.json";
import "@slidepig-example/decks/styles.css";

export default defineSite({
  title: "Presentations",
  description: "Audience variants from one shared content package.",
  decks,
  media,
  deckProps: { className: "sp-workspace-theme" },
});

To add a deck, create its file and add it to the registry. The reference package uses a wildcard ./decks/* export for optional individual imports, so neither the app nor the package's exports needs a per-deck edit. This is an explicit registry, not file discovery; the content package needs no import.meta.glob or Vite client types. Keep helper modules outside any deck-discovery glob if you use the starter's approach instead.

Media belongs to the content package

The site app points Vite at the content package's public directory and bundles its TypeScript source for the server renderer:

// apps/workspace-site/vite.config.ts
import { fileURLToPath } from "node:url";
import { defineConfig } from "vite";
import { slidepigSite } from "slidepig/site/vite";

export default defineConfig({
  publicDir: fileURLToPath(
    new URL("../../packages/example-decks/public", import.meta.url),
  ),
  ssr: { noExternal: ["@slidepig-example/decks"] },
  plugins: [slidepigSite()],
});

The app's build script runs:

slidepig assets --cwd ../../packages/example-decks && vite build

The paths are resolved from the site app. The assets command reads the content package's assets.config.ts, writes its manifest, and generates derivatives in that package's public/_media/. Vite copies that same public directory into the app's dist/. Export the manifest from the package and import it as shown above.

The reference uses the image pipeline's defaults, including WebP and AVIF sources. See the asset guide for overrides. Commit the original images and manifest; ignore derivatives in the content package as well as the app's build output. Each served site has one public directory, so choose distinct media paths when combining content collections.

Shared slides and styling

For slides declared outside defineDeck, use defineSlides with shared registries and a named collection or array:

import { defineSlides } from "slidepig";

export const shared = defineSlides(
  { backgrounds, media },
  {
    opening: {
      id: "opening",
      title: "An idea worth sharing.",
      layout: "hero",
    },
  },
);

Each deck includes the registries its shared slides reference and composes them as slides: [shared.opening, audienceSlide]. The helper checks media, theme, background, and layout names without manual generic parameters. SlideOf<typeof deck> derives the slide type from an existing deck. See the API reference for both collection forms. Slide paragraphs use body: [...]; expandable details use details: [{ title, text }].

The reference shares its theme with .sp-deck.sp-workspace-theme; the app's deckProps.className applies it to every deck, including newly added ones. Site pages also put data-deck="<registry-key>" on <div id="deck">, an ancestor of .sp-deck. Scope a single deck with [data-deck="partner-pitch"] .sp-deck. An embedded <Deck> can receive the same className; it does not get the site's data-deck wrapper automatically. Set --sp-font on the scoped .sp-deck for a shared font. Keep responsive overrides in the same scope. Backgrounds can supply color, tone, and a directional overlay.fade; slides can override those defaults. density: "compact" on the deck or a slide offers tighter built-in typography and spacing. See the styling API for precedence and fade stop tokens.

Artwork that arrives later

A background can omit src and use color or an existing placeholder image while final art is pending. To manage planned filenames, keep art.config.json in the content package and generate a plain background module with slidepig art. The manifest also records prompts, save paths, optional slide references, and provenance.

Enable generation and file watching in the site app's Vite plugin:

slidepigSite({ art: "../../packages/example-decks/art.config.json" });

The plugin regenerates the module when the manifest or planned files change, so adding a final image at its declared path updates the background without browser filesystem code or a content-package Vite glob. Import the generated data in the deck package; Node-only generation stays out of page bundles. From the content package, use slidepig art --status to see pending originals and --prompts for an image author's brief. See the art guide for the config and commands. Normal missing asset URLs still fail site builds.

Check the rendered slides

Typechecking and build validation catch data, HTML, links, and missing assets. For geometric checks, start the built preview and run the optional fit inspector against every deck URL at the intended sizes:

pnpm --filter slidepig-example-workspace-site exec slidepig inspect \
  http://localhost:4921/partner-pitch http://localhost:4921/team-update \
  --viewport 1440x810 --viewport 1024x768 --screenshots artifacts/fit

It activates presentation mode, waits for fonts and images, and reports overflow with slide IDs. Playwright is an optional development tool; the inspector can also return JSON for scripts. Inspect wide and narrow reading views and review any reported screenshots, tables, long titles, and custom visuals. Use F to present manually, ↑/↓ to visit slides, and Esc to return to reading. Reading-mode heights do not establish presentation fit.

Weight

The site tooling lives in the same package but loads only in Node: the Vite plugin and the build step use vite, html-validate and linkedom, which are optional peer dependencies. A page only ever loads slidepig/site/client, a few lines on top of slidepig. To put one deck on a page of an existing site, none of the build tools are needed.

Explore all guides · Getting started