- Documentation
- Write content
- Snippets
Snippets
Write text once in a snippet and use it on as many pages as you like.
A snippet is an MDX file in the snippets/ folder. Put it on a page with <Snippet>, and it shows there as if you had
written it in place.
Hello, Ada. This line lives in snippets/hello.mdx.
That line comes from snippets/hello.mdx:
Hello, {name}. This line lives in `snippets/hello.mdx`.and the page includes it like this:
<Snippet file="hello.mdx" name="Ada" />Import a snippet
Section titled “Import a snippet”You can also import a snippet and use it as a component. Imports go after the frontmatter:
import Hello from '/snippets/hello.mdx';
<Hello name="Ada" />Both forms work with the files in your docs folder’s snippets/ folder. A path that starts with / begins at the docs
folder.
filestringrequiredThe snippet’s file, as
hello.mdxor/snippets/hello.mdx.
any other propstringEach prop you add is a value the snippet reads by name in curly braces, as
{name}above.
A snippet can include other snippets. It’s published on every page that includes it, and never on its own, so you don’t
list it in docs.json.