Skip to main content
CodivDocs

Snippet

Reusable content blocks shared across pages — full resolution ships in Phase 4.

Status

<Snippet> is a stub component today. The file prop is accepted and the call site is forward-compatible, but content from _snippets/ is not yet inlined into the page. Full snippet resolution ships in Phase 4 alongside the OpenAPI parser (both touch the sync pipeline).

Usage (target API)

<Snippet file="_snippets/authentication.mdx" />

When Phase 4 ships, this will inline the contents of _snippets/authentication.mdx from your repo at sync time. The reader sees the full content; the snippet file is the single source of truth.

<!-- _snippets/authentication.mdx (in the tenant's repo) -->
Add your API key to the `Authorization` header:

```bash
curl -H "Authorization: Bearer YOUR_KEY" https://api.example.com/v1/users

## v0 escape hatch: inline children

Until Phase 4 lands, you can pass content inline as children. This skips the `_snippets/` lookup entirely and just renders whatever you pass:

```mdx
<Snippet>
  Add your API key to the `Authorization` header.
</Snippet>

Add your API key to the Authorization header.

This is identical to writing the content inline — there's no reuse benefit. The point is that authoring <Snippet> calls today is forward-compatible: when Phase 4 ships, you can swap inline children for the file prop without rewriting the call sites.

Why this matters

Snippets are how Mintlify (and the rest of the static-site-generator world) handle content reuse — boilerplate authentication intros, common warnings, shared error tables. Manual copy-paste is the alternative, which drifts the moment you update one and forget the others.

CodivDocs' Phase 4 implementation will:

  1. Walk the _snippets/ directory inside contentRoot during sync

  2. Store snippet bodies in a separate Postgres table keyed by file path

  3. Resolve <Snippet file="..."> references at render time by looking up the body

  4. Support template variable substitution via the vars prop

Variable substitution (Phase 4)

When Phase 4 ships, the vars prop will let you template-fill snippets per call site:

<Snippet
  file="_snippets/authentication.mdx"
  vars={{ apiKey: "YOUR_KEY", baseUrl: "https://api.example.com" }}
/>
<!-- _snippets/authentication.mdx -->
Add your key to `{baseUrl}`:

curl -H "Authorization: Bearer {apiKey}" {baseUrl}/v1/users

The {apiKey} and {baseUrl} placeholders get replaced with the values passed at the call site. The same snippet file can serve dozens of pages with different example values.

Props

PropTypeRequiredDescription
filestringNo (one of file or children)Path to snippet file relative to repo root
varsRecord<string, string>NoTemplate variable substitutions (Phase 4)
childrenReactNodeNo (v0 escape hatch)Inline content rendered as-is

Last updated April 12, 2026