Writing skills for guides and API reference for more consistent formatting. - `write-guide` - this skill helps create guides with progressive disclosure and a consistent format (intro, summary, step-by-step instructions, next steps). Works best when you give agents a demo. - `write-api-reference` - this skill looks at the API type (component, function, file, etc) and helps draft references following a consistent format. Works best when you give agents context. e.g. source code, PR descriptions, RFCs. Also explores repo context (e.g. e2e tests) Note: - While skills help you write a first draft, they’re 80%. Humans still need to check for accuracy, test APIs, and take it to 110%. - If no technical writing guidance is provided, skills work best when you give it references of past work. Closes: - https://linear.app/vercel/issue/DOC-6245/create-guide-skill - https://linear.app/vercel/issue/DOC-6246/create-api-reference-skill --------- Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
5.7 KiB
Next.js Documentation Conventions
Complete reference for frontmatter schema, code block formatting, and MDX component usage.
Frontmatter Schema
All MDX files must start with YAML frontmatter enclosed in --- delimiters.
Required Fields
| Field | Description | Example |
|---|---|---|
title |
Page title for SEO and headings (2-3 words) | title: Image Component |
description |
Brief description (1-2 sentences) | description: Optimize images using next/image. |
Optional Fields
| Field | Description | Example |
|---|---|---|
nav_title |
Shorter title for navigation sidebar | nav_title: Image |
source |
Pull content from another page (avoid duplication) | source: app/api-reference/components/image |
related |
Next steps section with related links | See below |
version |
Development stage indicator | version: experimental |
Related Links Format
---
title: My Feature
description: Description here.
related:
title: Next Steps
description: Learn more about related features.
links:
- app/api-reference/components/image
- app/guides/optimizing/images
---
Version Field Values
experimental- Experimental feature, may changelegacy- Legacy feature, consider alternativesunstable- Unstable API, not recommended for productionRC- Release candidate
Code Block Conventions
Basic Syntax
```language filename="path/to/file.ext"
code here
```
Required Attributes
| Attribute | When to Use | Example |
|---|---|---|
filename |
Always for code examples | filename="app/page.tsx" |
switcher |
When providing TS and JS variants | switcher |
highlight |
To highlight specific lines | highlight={1,3-5} |
TypeScript/JavaScript Switcher Pattern
Always provide TypeScript first, then JavaScript:
```tsx filename="app/page.tsx" switcher
import type { Metadata } from 'next'
export const metadata: Metadata = {
title: 'My Page',
}
```
```jsx filename="app/page.js" switcher
export const metadata = {
title: 'My Page',
}
```
Terminal Commands
Use bash language without filename:
```bash
npm install next
```
Highlighting Lines
highlight={1} # Single line
highlight={1,3} # Multiple lines
highlight={1-5} # Range
highlight={1,3-5,8} # Combined
MDX Components
AppOnly / PagesOnly
Use for router-specific content in shared documentation:
<AppOnly>
This content only appears in App Router documentation.
</AppOnly>
<PagesOnly>
This content only appears in Pages Router documentation.
</PagesOnly>
Important: Include blank lines inside the components for proper markdown parsing.
Image Component
For themed images with light/dark variants:
<Image
alt="Description of the image"
srcLight="/docs/light/image-name.png"
srcDark="/docs/dark/image-name.png"
width={1600}
height={800}
/>
Notes and Callouts
Single line:
> **Good to know**: Important information here.
Multi-line:
> **Good to know**:
>
> - First point
> - Second point
> - Third point
Props Tables
Use HTML table wrapper for horizontal scroll on mobile:
<div style={{ overflowX: 'auto', width: '100%' }}>
| Prop | Example | Type | Status |
| ----------------- | ------------------- | ------- | -------- |
| [`src`](#src) | `src="/image.png"` | String | Required |
| [`alt`](#alt) | `alt="Description"` | String | Required |
| [`width`](#width) | `width={500}` | Integer | - |
</div>
Status Values
Required- Must be provided-- OptionalDeprecated- Will be removed, use alternative
Shared Content Pattern
For Pages Router docs that share content with App Router:
App Router (source): docs/01-app/03-api-reference/02-components/image.mdx
- Contains the full documentation
- Uses
<AppOnly>and<PagesOnly>for router-specific sections
Pages Router (consumer): docs/02-pages/03-api-reference/01-components/image.mdx
---
title: Image Component
description: Optimize images using next/image.
source: app/api-reference/components/image
---
The source field pulls content from the App Router doc.
Writing Style
Voice
- Guides: Instructional, use "you" to address users
- API Reference: Technical, use imperative verbs ("create", "pass", "return")
Clarity
- Use plain words over complex alternatives
- Be specific: "the
srcprop" not "this prop" - Avoid jargon unless explaining it
Structure
Typical page structure:
- Brief introduction (what and why)
- Minimal working example
- Detailed reference/options
- Examples for different use cases
- Related links (via frontmatter)
File Naming
- Use kebab-case:
generate-metadata.mdx - Add numeric prefix for ordering:
01-installation.mdx - Index pages:
index.mdx
Validation Commands
pnpm lint # Full lint check
pnpm prettier-fix # Fix formatting
pnpm types # TypeScript check