Installation
Install svedocs in a new project, wire it into an existing SvelteKit app, and keep the framework dependencies current.
You can generate a new project or add svedocs to an existing SvelteKit app. For a new site, the template is usually faster because it already contains the routes, config, content folders, and server endpoints.
Requirements
- Node.js 20.19 or newer.
- A SvelteKit project using ESM.
- pnpm, npm, yarn, or bun. The templates default to pnpm because the repository itself uses pnpm.
Create a new project
Shellpnpm create svedocs my-docs --template docscd my-docspnpm installpnpm dev
The create-svedocs package forwards the command to svedocs-cli. The CLI downloads the selected template from GitHub, uses its bundled copy if GitHub is unavailable, and updates the project name and package manager. Pass --install when you also want it to install dependencies.
Template dependencies are normal registry dependencies:
JSONpackage.json{ "dependencies": { "svedocs": "latest" }, "devDependencies": { "svedocs-cli": "latest" }}
With --install, your chosen package manager installs these packages from its configured registry. No framework source is copied into the project.
Choose a template
Shellpnpm create svedocs my-docs --template minimalpnpm create svedocs my-docs --template docspnpm create svedocs my-docs --template cloudflare
| Template | Included routes | Best for |
|---|---|---|
minimal | Docs shell and content routes. | Learning the basics or embedding docs into an existing app. |
docs | Search, Ask AI fallback, sitemap, robots, and OG routes. | Most product documentation sites. |
cloudflare | Everything in docs, plus Wrangler config and Cloudflare binding examples. | Cloudflare Pages and edge-first projects. |
Remote template behavior can be controlled with environment variables:
| Variable | Purpose |
|---|---|
SVEDOCS_TEMPLATE_SOURCE=bundled | Force the CLI-bundled template copy. |
SVEDOCS_TEMPLATE_SOURCE=github | Require GitHub and fail instead of falling back. |
| `SVEDOCS_TEMPLATE_REF=<branch | tag |
SVEDOCS_TEMPLATE_REPOSITORY=<owner/repo> | Fetch templates from a different repository. |
Add svedocs to an existing app
Install the framework and CLI:
Shellpnpm add svedocspnpm add -D svedocs-cli
Create svedocs.config.ts:
TypeScriptsvedocs.config.tsimport { defineConfig } from 'svedocs/config';export default defineConfig({ site: { name: 'My docs', title: 'My docs', description: 'Documentation for my product', url: 'https://example.com' }, content: { root: 'content', docs: 'content/docs', pages: 'content/pages' }});
Register the Vite plugin:
TypeScriptvite.config.tsimport { svedocs } from 'svedocs/vite';import svedocsConfig from './svedocs.config';export default { plugins: [ svedocs({ config: svedocsConfig }) ]};
Import the default theme CSS once in the root layout:
Sveltesrc/routes/+layout.svelte<script> import 'svedocs/theme/styles.css';</script><slot />
Then add the routes your site needs. A minimal setup can render DocsApp from svedocs/theme; the docs and cloudflare templates show the complete search, Ask AI, sitemap, robots, and OG setup.
Add content
Create the content roots and a first docs page:
Shellmkdir -p content/docs content/pages
Markdowncontent/docs/index.md---title: Introductiondescription: Start here to understand the product.order: 1---# IntroductionWelcome to the docs.
Verify the installation
Run these commands before adding hosted integrations:
Shellpnpm checkpnpm build
pnpm check validates the content manifest. pnpm build verifies that SvelteKit, the svedocs Vite plugin, route files, theme imports, and configured build mode all work together.
Upgrade svedocs
Generated projects include both svedocs and svedocs-cli. Upgrade them together:
Shellsvedocs upgradesvedocs upgrade 0.2.0svedocs upgrade 0.2.0 --no-installsvedocs upgrade --check-only
Before changing dependencies, the upgrade command checks whether the requested version crosses a known breaking release. There are no special migration rules yet; future releases can add them when needed.
Troubleshooting
| Symptom | Check |
|---|---|
| The docs page renders without styles. | Confirm svedocs/theme/styles.css is imported from the root layout. |
| Routes do not update while editing content. | Confirm svedocs({ config }) is registered in vite.config.ts. |
| Search route works locally but not in production. | Confirm provider credentials or Cloudflare bindings exist in the runtime environment. |
Build fails in spa mode. | Prefer edge or static; use spa only for constrained hosts that need a fallback. |