Margin is a modern, agent-first framework for documentation. It turns a folder of Markdown or MDX into a searchable site backed by Postgres, and serves the same content to readers and to AI agents.
- Zero config to start. One
.mdxfile is a site. Navigation and titles come from your files, frontmatter, and optionalmeta.json. - Optional
docs.json. Colors, fonts, navigation, redirects, versions, and OpenAPI pages, compatible with Mintlify'sdocs.json. - Built for agents. Markdown and PDF twins of every page,
llms.txt, an MCP server, skills, and an optional AI assistant. - Safe by default. MDX is validated at ingest and server-rendered in an isolate with no host access.
- Immutable deployments. Each commit becomes its own content version, so previews and rollbacks serve exactly what was built.
Built with TanStack Start, fumadocs, and Postgres. Licensed under Apache-2.0.
The button clones this repository and provisions a Neon Postgres database.
Enter a SITE_NAME when asked. To publish, edit docs/ in your copy and push.
You need no other accounts or credentials. See the
deployment guide for self-hosting, retention, and rollbacks.
You need Bun, Node.js 24 or newer, and Docker.
bun install
cp .env.example .env
docker compose up -d --wait postgres
bun run db:migrate
bun run devThe site runs at http://localhost:3000 and picks up edits to docs/.
Run docker compose down to stop the database.
docs.json is optional:
{
"name": "Example Docs",
"colors": { "primary": "#2563EB" },
"navigation": { "groups": [{ "group": "Start", "pages": ["index", "deploy"] }] },
"x-margin": { "search": { "mode": "static" } }
}Margin-specific settings live under x-margin. Outside Vercel, the only
required environment variables are DATABASE_URL and SITE_ORIGIN.
- Configuration: files,
docs.json, versions, icons, and environment variables - Deployment: Vercel, self-hosting, content versions, and rollbacks
- Extensions: replace request policy, site resolution, and telemetry
- Agents and link relations: Markdown, LLM indexes, MCP, and skills
- Deployment standard: every supported field and the MDX security contract
See CONTRIBUTING.md. Report vulnerabilities as described in SECURITY.md. Third-party fonts and icons are credited in NOTICE.
Originally built by Manicule.