yaakdoc

Vite

Serve the docs from a Vite-based app (Vite, React Router, SvelteKit, Astro, ...) with yaakdoc/vite.

The yaakdoc/vite plugin adds the docs to any app built with Vite: plain Vite, React Router, SvelteKit, Astro and others.

npm i -D yaakdoc
vite.config.ts
import { defineConfig } from "vite";
import yaakdoc from "yaakdoc/vite";

export default defineConfig({
  plugins: [
    yaakdoc({
      path: "/docs",
      export: "./api/yaak.json",
      config: {
        branding: {
          title: "Acme API"
        }
      },
    }),
  ],
});
  • Dev. vite dev serves the live docs: server-rendered, with HMR, and a reload when the export changes.
  • Build. vite build prerenders the docs and adds them to the app's client output (e.g. dist/docs/), so they're deployed with the app.

yaakdoc runs its own Vite instance, so your app's Vite config and plugins don't affect the docs.

Options

The plugin takes the same options as every integration. cwd defaults to the Vite root.

OptionDescription
pathWhere the docs are served. Default: /docs. It takes precedence over config.base.
configyaakdoc config, merged over yaakdoc.config.* if there is one. Paths are relative to cwd.
exportPath of the Yaak export. Shorthand for config.export. By default, yaakdoc.json, then yaak.json, is looked up in cwd.
cwdProject directory. Default: the Vite root.
configFileAn explicit config file, or false to not look for one.
publicDirA folder copied to the docs' root as is. Default: none, because the app's public/ folder isn't meant for the docs.

On this page