---
title: "Snippets"
description: "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`:

```mdx snippets/hello.mdx
Hello, {name}. This line lives in `snippets/hello.mdx`.
```

and the page includes it like this:

```mdx
<Snippet file="hello.mdx" name="Ada" />
```

## Import a snippet

You can also import a snippet and use it as a component. Imports go after the frontmatter:

```mdx
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.

- `file` (string, required): The snippet's file, as `hello.mdx` or `/snippets/hello.mdx`.

- `any other prop` (string): Each 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`.
