Quickstart
Shipping docs inside an npm package?
This quickstart covers site mode (docs website). For npm-bundled docs, follow Bundle docs into a package instead.
This is the GA happy path: one MDX source, one docs route, and one generated artifact set for agents.
Install
npm install leadtypeFastest: scaffold with leadtype init
In an existing app, leadtype init writes the integration for you — a starter
docs/ source, the docs route, the markdown route, config, and a generated set
of agent artifacts — then runs leadtype generate so the site works on the
first dev.
The last line is the root-AGENTS.md pointer: init adds (or merges, never overwrites) a marked block pointing your coding agent at node_modules/leadtype/AGENTS.md, so any agent using leadtype or editing your docs reads leadtype's own version-matched docs. Re-running refreshes the block in place.
Supported targets: next, astro, nuxt, sveltekit. Run with --dry-run
to preview the file list, or --base-url, --name, and --summary to seed the
config. For TanStack Start and Fumadocs (heavier app-specific setup), follow the
recipes in Use the source primitive and
Integrate with Fumadocs.
init scaffolds the local-docs/ case. If your docs live in another repo,
or you're adding Leadtype to an app with an existing structure, hand a coding
agent one of the agent setup prompts instead
— it adapts to your real layout.
That's the whole quickstart if you let the CLI scaffold it. The steps below
walk through the same wiring by hand — read them to understand what init
generated or to customize it. Steps 1, 2, 4, and 5 are framework-neutral; only
step 3 (rendering) varies by framework.
1. Author one page
Every page needs a title. Add description so generated llms.txt, search results, and bundled AGENTS.md can route readers without guessing from the body.
Add a small config next to the docs source:
navigation is the shared source of truth for the sidebar, llms.txt, AGENTS.md, sitemap markdown, and Agent Readability metadata.
2. Create the source
That's the framework-neutral primitive. You can now call:
source.loadPage(slug)— resolved markdown + AST + frontmatter + TOCsource.listPages()— every page's slug, urlPath, and metadatasource.getNavigation()— grouped sidebar treesource.buildSearchIndex()— static search bundlesource.resolveInclude(specifier)— standalone include resolver
3. Render the docs route
Step 3 is the only step that varies by framework — here's what it looks like in Next App Router. The same createDocsSource() from step 2 powers every framework; pick yours below the code block to see the equivalent wiring.
The UI is yours. Leadtype provides page loading, navigation, markdown output, table of contents data, include resolution, and search input data.
Pick your framework
Next App Router
Catch-all route + @next/mdx + createMdxSourcePlugins().
TanStack Start
@mdx-js/rollup + viteReact + TanStack Router catch-all.
Nuxt
@nuxtjs/mdc + createMdxSourcePlugins().
Astro Content Collections
@astrojs/mdx + createMdxSourcePlugins(). Compose with Astro's native content schema.
SvelteKit
mdsvex preprocessor + createMdxSourcePlugins().
Fumadocs
First-party leadtype/fumadocs adapter — Source interface + meta.json.
4. Generate agent artifacts
Run the site-mode CLI before your app build:
That writes the hosted files agents need:
Keep this command in your build script so browser docs, markdown mirrors, search, and agent discovery files stay in sync.
5. Verify the output
Before publishing, check the files that prove the pipeline worked:
Then add runtime handling for markdown responses, sitemap/robots regeneration, and JSON-LD with Serve agent responses.
Common next steps
| Goal | Go to |
|---|---|
| Compare every hosted-site integration shape | Build a docs site |
| Serve markdown, sitemaps, robots, and JSON-LD for agents | Serve agent responses |
| Add local search or source-grounded answers | Add search |
| Combine local folders, mounted folders, or remote git repos | Configure docs sources |
| Publish version-matched docs inside an npm package | Bundle docs into a package |
| Validate frontmatter, links, and nav in CI | Validate in CI |