Configuration
Package exports, the docsmith() options, and the two shell components.
Everything you wire up once: what the package exports, the one docsmith() call
that configures the whole site, and the two page-level components that own the
site chrome. Props
for the authoring components (Callout, Tabs, Badge, and the rest) live on
their own pages in the Components section.
Package exports
svelte-docsmith: every component, pluscreateSearchEngineand the types. Components are documented in Components; the rest is below.svelte-docsmith/server: ready route handlers for the files a site serves besides its pages:sitemap,changelogFeed,llmsTxt,llmsFullTxt,agentMarkdown(the.mdpage twins),ogImagesandmcpServer. Each is one line in a+server.tsthat reads your site config itself (see SEO, Changelog and MCP server). Server-only.svelte-docsmith/vite: thedocsmith()Vite plugin, the one place a site is configured. It compiles markdown pages, builds the content, search, llms and changelog indexes, and serves the?sourceand?propsimports.svelte-docsmith/site: your site config, thesiteoptions ofdocsmith(), exported assite, with the resolved outside paths asoutsideand the repo’s star count asgithubStars.DocsShell,ErrorPageand the route handlers read it themselves; import it when a page of your own needs the title or links.svelte-docsmith/reader-events: your reader event handler, the default export of the modulereaderEventsnames, which the components report to. You never import it directly.svelte-docsmith/content: the generated sidebar index. Itscontentexport (the pages asdocsplus the version manifest asversions) is whatDocsShellandErrorPagetake.svelte-docsmith/search: the generated full-text search index, exported asdocs(lazy-load it; see Search).svelte-docsmith/llms: the generated per-page agent markdown index, with props tables and example code written out, exported asdocs(see SEO).svelte-docsmith/changelog: the generated release index, exported asreleases, with the route it is served at aschangelogPath(see Changelog).svelte-docsmith/mermaid: the diagram component, imported for you by a```mermaidfence. You never import it directly.svelte-docsmith/theme.css: the base style contract.svelte-docsmith/themes/*.css: the presets as theme files. Choose one withthemerather than importing it (see Theming).
docsmith()
From svelte-docsmith/vite, added to plugins in vite.config.ts before sveltekit(). It is the only place your docs are configured: it compiles your
markdown pages, scans them into the generated indexes, serves the ?source imports that Live Examples use and the ?props imports
behind generated Props Tables, and serves your
site config to the shell and the route handlers. Only site.title is required.
The options are checked when Vite starts, so a mistyped option fails dev and build with a message that names it. Because they live in vite.config.ts,
editing them restarts the dev server.
site required DocsmithSite content string default 'src/routes/docs'routes string default 'src/routes'versions DocsVersions theme string default 'darkmatter''ocean') or a path to a theme file
('./src/theme.css'), relative to the Vite root. See Theming.codeTheme { light: string; dark: string } themes, which still works until the
next minor.markdown DocsmithMarkdownOptions changelog { file?: string; path?: string }false file is the
changelog that feeds the release index (default 'CHANGELOG.md'; point
it at the package you publish). path is the route it is served at
(default '/changelog'): the feed from changelogFeed() links
there, and hand-written per-release pages are found under it. false skips the changelog.tsconfig string default 'tsconfig.json'?props imports, relative to
the Vite root. Experimental.schema StandardSchemaV1 links DocsmithLinksOptions readerEvents string site
What the header, footer and head tags show. The plugin serves it as svelte-docsmith/site, where DocsShell, ErrorPage and the route handlers read it, so you never pass it around. It reaches the
browser as JSON, so it must be plain data: strings, numbers, booleans, arrays
and plain objects.
title required string <title> suffix.description string url string <link rel="canonical"> and absolute Open Graph URLs.ogImage string url).
With ogImages set, only pages that aren't doc pages use it.ogImages string /og. Each doc page's social-share image becomes its own,
at /og/<page path>.png.editUrl string https://github.com/you/repo/edit/main/apps/docs. Each page's source
path is appended. (“Last updated” is added from git automatically.)mcp string /mcp, or a
full URL. Adds “Connect to your editor” to the copy-page menu. Experimental.github string https://github.com/owner/repo URL also shows the repo's star count.githubStars boolean default truefalse to
skip both the build-time fetch and the browser fallback, and show the bare link.version string logo string nav DocsmithLink[] announcement { text, tag?, href?, external?, id?, dismissible? } text is required; add a tag for a leading pill (e.g. "New") and an href to link it. It's dismissible by default and stays dismissed
until you change id (or the text), so bump id to
re-show a new announcement.footer { copyright?, columns?, poweredBy? } This site runs one: the thin bar above the header is site.announcement. Its id tracks the library version, so it returns after each release and stays out
of the way in between. Dismiss it and it holds until the next version.
A page of your own can read the same config, for example a landing page that shows the site title:
GitHub stars
When github is a https://github.com/owner/repo URL, the header GitHub link
shows the repo’s star count, like this site’s. Readers star the repo by
clicking through to GitHub.
The plugin asks the GitHub API for the count once per build, and once each time vite dev starts, then serves it with the site config, so readers get it with
the page and their browsers never call GitHub. Other hosts, and GitHub URLs that
name no repo, get the plain link with no count.
GitHub allows 60 unauthenticated requests an hour per IP address, and CI and hosting build machines (Vercel, Netlify, GitHub Actions) often share one that has already used them up. When the build can’t get the count, it logs a warning and the header falls back to asking GitHub from each reader’s browser instead: one request per reader, cached in their browser for a day, so it stays well inside each reader’s own allowance. The count then appears just after the page loads. A failure there leaves the plain link, and never fails the build.
To bake the count in and skip the browser request, set a GITHUB_TOKEN environment variable in your build; the plugin sends it, which raises the limit
to 5,000 an hour. A fine-grained token with no permissions is enough for a
public repo. Set githubStars: false to turn the count off entirely, build and
browser both.
A page of your own can show the build-time count too. githubStars is undefined whenever the build had none to show:
markdown
How markdown pages are compiled. The plugin runs mdsvex, Shiki, heading anchors
and the page layout over every .md file before SvelteKit compiles it, so
markdown pages are real routes and there is no preprocessor to register. Every
option has a working default.
extensions string[] default ['.md']sveltekit({ extensions }); the plugin warns
when one is missing.langs string[] layout stringfalse false for none. A
custom layout must export a pre component from its module
script, since code fences render through it. Under a custom layout, images
are plain (no zoom or captions) and install blocks show their npm commands.lineNumbers boolean default falseshowLineNumbers or noLineNumbers.twoslash boolean default falsetwoslash. Needs the optional
peer dependencies; see Code blocks.math boolean default false$…$ and $$…$$ as formulas, written as MathML at
build time. Needs the optional peer dependency temml; see Math.remarkPlugins PluggableList rehypePlugins PluggableList links
How the links your doc pages write are treated. vite build checks every link
to a path under the docs base and, by default, fails on one with no page or
anchor behind it. See Links for what counts as a broken link and
a worked example of outside paths.
broken 'error''warn''ignore' default 'error'vite build: 'error' prints
every one and fails, 'warn' prints them and builds, 'ignore' skips the check. vite dev only ever warns.outside string[] default []/ and
matches whole segments. A link to one is never broken, and doc pages and the
shell's site config links mark it rel="external". See Outside paths.DocsShell
The full documentation shell: header, sidebar, content area, and table of contents.
It reads the site config from svelte-docsmith/site itself. To replace its
sidebar, table of contents, page header or pager, pass an override.
content required DocsContent content export of svelte-docsmith/content: every page,
which the sidebar is derived from, and the version manifest, which scopes the
sidebar, search, prev/next and breadcrumbs to the version being read (see Versioning). A bare docs array still works.children required Snippet versions deprecated ResolvedVersion[] default []content is a bare docs array. Pass the content export instead, which carries the versions.search (versionId?: string) => Promise<SearchDoc[]> () => import('svelte-docsmith/search').then((m) => m.docs).
Receives the active version id on a versioned site.
See Search.seo { title?: string; description?: string } logo Snippet actions Snippet footer Snippet pattern boolean default falsecopyPage boolean default false.md, or open in ChatGPT / Claude). Needs the .md endpoint. See SEO. With site.mcp set, it also
offers “Connect to your editor”.readingTime boolean default truefalse to hide it.feedback boolean feedback reader events. Passing a callback (vote, path) => void still works but is deprecated, and stops working
in the next minor.layout 'docs''page' default 'docs'docs is the three-column shell; page is full-bleed
content with the same header and footer but no sidebar or TOC.sidebar Snippet<[SidebarProps]> { nav }. See Overrides.toc Snippet<[TableOfContentsProps]> { items, activeId }. See Overrides.pageHeader Snippet<[PageHeaderProps]> { path, breadcrumbs, readingMinutes, copyPage }. See Overrides.pager Snippet<[PagerProps]> { prev, next }.
See Overrides.Colour mode needs no setup
ModeProvider and ModeToggle handle light and dark with no consumer wiring. DocsShell mounts the provider internally, so you never touch mode-watcher yourself. Use ModeProvider directly to wrap a page you build outside DocsShell. (They were called ThemeProvider and ThemeToggle; the old names
still work until the next minor.)
ErrorPage
A styled 404 / error screen that keeps the site chrome (header, search, footer,
theme). Drop it into a SvelteKit +error.svelte:
Like DocsShell, it reads the site config itself, so the chrome matches.
content DocsContent content as DocsShell, so the header and footer nav
still work, and an error under an archived prefix keeps that version's search
scope and noindex.status number default page.statustitle string default from statusmessage string default page.error.messagehome string default '/'homeLabel string default 'Back to home'versions deprecated ResolvedVersion[] default []content is a bare docs array, as for DocsShell.search (versionId?: string) => Promise<SearchDoc[]> DocsShell).Types
DocsmithSite: thesiteoptions above, assvelte-docsmith/siteserves them.DocsmithOptions/DocsmithMarkdownOptions/DocsmithChangelogOptions/DocsmithLinksOptions/BrokenLinksLevel: the options ofdocsmith(), fromsvelte-docsmith/vite.DocsContentItem: a content-index entry withtitle,path, and optionalsection,order,description,toc, anddata.DocsCustomFields: the type ofdata, a page’s custom fields. Extend it to type yours. See Custom fields.SearchDoc/SearchResult/SearchEngine: the search index entry and the shape returned bycreateSearchEngine.ResolvedVersion: one entry of the generated version manifest. See Versioning.DocsContent: thecontentexport,{ docs, versions }, thatDocsShellandErrorPagetake.SitemapOptions/SitemapEntry: whatsitemap()insvelte-docsmith/servertakes.CalloutVariant/BadgeVariant: the intent unions forCalloutandBadge.ReaderEvent/ReaderEventHandler: a reader event and the handler’s type. Each event type is exported too (FeedbackEvent,FeedbackLinkEvent,SearchEvent,NotFoundEvent,PageActionEvent,CopyCodeEvent), withPageActionfor the Copy page menu’s actions.SidebarProps/TableOfContentsProps/PageHeaderProps/PagerProps: what each override receives, and the props ofSidebar,TableOfContents,PageHeaderandPager.NavGroup,NavItem,NavNode,BreadcrumbandTocItemare what they carry.
The vendored shadcn primitives and internal helpers (the TOC engine, the clipboard utility, the markdown renderer map) are not part of the public API and may change between releases.