CLI reference
Every docvia command and flag: init, build, dev, and preview.
The docvia command is provided by @docvia/cli. Install it
as a dev dependency and invoke it through your package manager:
pnpm add -D @docvia/cli
npx docvia <command>
Run docvia --version to print the installed version.
flowchart LR I["docvia init<br/><i>scaffold docs/ + config</i>"] --> B["docvia build<br/><i>compile once</i>"] I --> D["docvia dev<br/><i>build, then watch</i>"] B --> P["docvia preview<br/><i>serve .docvia/</i>"] D --> P
docvia init
Scaffold a new docvia project.
docvia init [-d <dir>] [-r react|svelte|none] [-f]
| Flag | Default | Description |
|---|---|---|
-d, --dir <dir> | "." | Project directory to scaffold into. |
-r, --renderer <name> | autodetected | react, svelte, or none. |
-f, --force | false | Overwrite an existing docvia.config.ts. |
When --renderer is omitted, init reads the target package.json: svelte
or @sveltejs/kit selects the Svelte template, react or next selects the
React template, and anything else falls back to none.
init creates a docs/ directory with sample pages (index.md,
getting-started.md, components.md) and a working docvia.config.ts. It
refuses to overwrite an existing config unless you pass --force, and prints
the install commands for the renderer you chose.
docvia build
Compile every Markdown file once.
docvia build [--docs <dir>] [--out <dir>] [--config <path>] [--no-cache]
| Flag | Default | Description |
|---|---|---|
--docs <dir> | from config | Override sourceDir. |
--out <dir> | from config | Override outDir. |
--config <path> | ./docvia.config.ts | Path to the config file. |
--no-cache | none | Disable the incremental cache; force a full rebuild. |
build loads the config, then compiles every file to the module graph in
outDir and persists .docvia.cache.json. It fails with a CONFIG_ERROR if
the docs directory is missing or no renderer is configured. On success it
prints the build duration and the file and page counts, noting how many files
were served from cache.
docvia dev
Build once, then watch and rebuild incrementally.
docvia dev [--docs <dir>] [--out <dir>] [--config <path>]
| Flag | Default | Description |
|---|---|---|
--docs <dir> | from config | Override sourceDir. |
--out <dir> | from config | Override outDir. |
--config <path> | ./docvia.config.ts | Path to the config file. |
dev does an initial build, then watches both sourceDir and the config file
on a single long-lived CompileService. Each change recompiles only the
affected files through the service's incremental invalidate(), so a full
rebuild is not repeated per change. A config change recreates the service. An
initial-build failure does not stop the watcher; fix the error and save again.
Ctrl+C shuts the watcher down cleanly.
docvia devis a standalone watcher for the.docvia/output. When docvia is embedded in a Vite or Next.js app, the framework integration runs the compile core in-process and handles watching itself. See Framework integration.
docvia preview
Serve the compiled .docvia/ output.
docvia preview [--out <dir>] [-p <port>]
| Flag | Default | Description |
|---|---|---|
--out <dir> | .docvia | Output directory to serve. |
-p, --port <port> | 4173 | Port to listen on. |
preview serves outDir over sirv. It is a sanity check for the compiled
module graph, not a runtime. Use a framework integration for a real site.
Programmatic use
The CLI is also importable. runCli is the entry point the docvia binary
calls, and defineConfig is re-exported for authoring docvia.config.ts:
import { runCli } from "@docvia/cli";
await runCli(["node", "docvia", "build", "--no-cache"]);
See @docvia/cli for the full package reference.