Leadtype
Documentation

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 leadtype

Fastest: 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

docs/index.mdx

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:

docs/docs.config.ts

navigation is the shared source of truth for the sidebar, llms.txt, AGENTS.md, sitemap markdown, and Agent Readability metadata.

2. Create the source

lib/source.ts

That's the framework-neutral primitive. You can now call:

  • source.loadPage(slug) — resolved markdown + AST + frontmatter + TOC
  • source.listPages() — every page's slug, urlPath, and metadata
  • source.getNavigation() — grouped sidebar tree
  • source.buildSearchIndex() — static search bundle
  • source.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.

app/docs/[[...slug]]/page.tsx

The UI is yours. Leadtype provides page loading, navigation, markdown output, table of contents data, include resolution, and search input data.

Pick your framework

4. Generate agent artifacts

Run the site-mode CLI before your app build:

That writes the hosted files agents need:

public/
llms.txt
llms-full.txt
docs/
index.md
llms.txt
search-index.json
search-content.json
sitemap.xml
sitemap.md
robots.txt
agent-readability.json

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

GoalGo to
Compare every hosted-site integration shapeBuild a docs site
Serve markdown, sitemaps, robots, and JSON-LD for agentsServe agent responses
Add local search or source-grounded answersAdd search
Combine local folders, mounted folders, or remote git reposConfigure docs sources
Publish version-matched docs inside an npm packageBundle docs into a package
Validate frontmatter, links, and nav in CIValidate in CI