write-api-reference by vercel/next.js
npx skills add https://github.com/vercel/next.js --skill write-api-reference生成一个 API 参考页面,用于记录单个 API 接口(函数、组件、文件约定、指令或配置选项)。该页面应简洁、易于浏览且以示例驱动。
每个页面记录一个 API。如果 API 包含子方法(如 cookies.set()),则在同一页面上记录它们。如果两个 API 是独立的,则应分别建立页面。
确定 API 所属的类别,然后遵循相应的模板。
cookies, fetch, generateStaticParams): 签名、参数/返回值、方法表、示例Link, Image, Script): 属性摘要表、单个属性文档、示例广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
pagelayoutrouteuse client, use cache): 定义、用法、序列化/边界规则、参考basePath, images, 等): 定义、配置代码、行为部分---
title: {API 名称}
description: {关于 {API 名称} {函数|组件|文件约定|指令|配置选项} 的 API 参考。}
---
{一句话定义其功能及使用场景。}
```tsx filename="path/to/file.tsx" switcher
// 最小化工作示例
```
```jsx filename="path/to/file.js" switcher
// 相同的 JS 示例
```
## 参考
{对于函数:方法/参数表,返回类型。}
{对于组件:属性摘要表,然后是 `#### 属性名` 子章节。}
{对于文件约定:`### 属性` 部分包含 `#### 属性名` 子章节。}
{对于指令:用法规则和序列化约束。}
{对于配置:选项表或单个选项文档。}
### {子章节名称}
{描述 + 代码示例 + 适用的值表。}
## 须知
- {默认行为或隐式效果。}
- {注意事项、限制或版本特定说明。}
- {开发者应注意的边缘情况。}
## 示例
### {示例名称}
{简要背景,1-2 句话。}
```tsx filename="path/to/file.tsx" switcher
// 完整的工作示例
```
```jsx filename="path/to/file.js" switcher
// 相同的 JS 示例
```
## 版本历史
| 版本 | 变更说明 |
| ---------- | ---------------- |
| `vX.Y.Z` | {变更内容。} |
特定类别说明:
await。如果返回值包含方法(如 cookies),则在表格中记录方法。如果适用,在单独的表格中记录选项。| 属性 | 示例 | 类型 | 是否必需 |)。然后在 #### 属性名 下记录每个属性,包含描述、代码示例以及有用的值表。#### 属性名 下记录每个属性 (params, searchParams 等),并附上路由/URL/值示例表。## 参考 部分。改用 ## 用法,展示正确的放置位置。记录序列化约束和边界规则。next.config.ts 代码片段。为每个行为方面使用子章节。## 参考 之前,放置一个最小化使用示例。switcher。 始终包含两者。始终包含 filename="path/to/file.ext"。highlight={n}。 高亮显示演示所记录 API 的那一行。#### 子章节。> **须知**: 或 ## 须知。 对于简短说明(1-3 个要点)使用块引用格式。对于较长的部分使用标题格式。不要用"注意:"或"警告:"。### 示例名称 子章节。 每个示例解决一个特定的用例。/docs/app/... 格式。| 避免使用 | 应该使用 |
|---|---|
| "这个强大的函数让你可以轻松管理 cookies" | "cookies 是一个异步函数,用于在服务器组件中读取 HTTP 请求的 cookies" |
| "你可以方便地访问..." | "返回一个包含...的对象" |
| "处理导航的最佳方式" | "<Link> 扩展了 HTML <a> 元素,以提供预取和客户端导航功能" |
test/ 中搜索使用该 API 的测试,以找到真实的使用模式、边缘情况和预期行为。switcher/filename、表格与子章节的使用、"须知"格式、没有长破折号、机械语言。在编写之前,请阅读 docs/01-app/03-api-reference/ 中的这些页面。它们展示了上述模式。
04-functions/cookies.mdx - 包含方法表、选项表和行为说明的函数03-file-conventions/page.mdx - 包含属性子章节和路由/URL/值表的文件约定02-components/link.mdx - 包含属性摘要表和详细属性文档的组件01-directives/use-client.mdx - 包含用法部分和序列化规则的指令04-functions/fetch.mdx - 包含故障排除部分和版本历史的函数每周安装量
108
代码仓库
GitHub 星标数
138.5K
首次出现
11 天前
安全审计
安装于
opencode103
gemini-cli102
codex102
cursor102
github-copilot102
amp101
Produce an API reference page that documents a single API surface (function, component, file convention, directive, or config option). The page should be concise, scannable, and example-driven.
Each page documents one API. If the API has sub-methods (like cookies.set()), document them on the same page. If two APIs are independent, they get separate pages.
Identify which category the API belongs to, then follow the corresponding template.
cookies, fetch, generateStaticParams): signature, params/returns, methods table, examplesLink, Image, Script): props summary table, individual prop docs, examplespage, layout, route): definition, code showing the convention, props, behavior, examplesuse client, use cache): definition, usage, serialization/boundary rules, referencebasePath, images, etc.): definition, config code, behavioral sections---
title: {API name}
description: {API Reference for the {API name} {function|component|file convention|directive|config option}.}
---
{One sentence defining what it does and where it's used.}
```tsx filename="path/to/file.tsx" switcher
// Minimal working usage
```
```jsx filename="path/to/file.js" switcher
// Same example in JS
```
## Reference
{For functions: methods/params table, return type.}
{For components: props summary table, then `#### propName` subsections.}
{For file conventions: `### Props` with `#### propName` subsections.}
{For directives: usage rules and serialization constraints.}
{For config: options table or individual option docs.}
### {Subsection name}
{Description + code example + table of values where applicable.}
## Good to know
- {Default behavior or implicit effects.}
- {Caveats, limitations, or version-specific notes.}
- {Edge cases the developer should be aware of.}
## Examples
### {Example name}
{Brief context, 1-2 sentences.}
```tsx filename="path/to/file.tsx" switcher
// Complete working example
```
```jsx filename="path/to/file.js" switcher
// Same example in JS
```
## Version History
| Version | Changes |
| -------- | --------------- |
| `vX.Y.Z` | {What changed.} |
Category-specific notes:
await if async. Document methods in a table if the return value has methods (like cookies). Document options in a separate table if applicable.| Prop | Example | Type | Required |). Then document each prop under #### propName with description, code example, and value table where useful.params, searchParams, etc.) under #### propName with a route/URL/value example table.## Reference section. Use instead, showing correct placement. Document serialization constraints and boundary rules.## Reference.switcher for tsx/jsx pairs. Always include both. Always include filename="path/to/file.ext".highlight={n} for key lines. Highlight the line that demonstrates the API being documented.#### subsection.> **Good to know**:or## Good to know. Use the blockquote format for brief notes (1-3 bullets). Use the heading format for longer sections. Not "Note:" or "Warning:".| Don't | Do |
|---|---|
| "This powerful function lets you easily manage cookies" | "cookies is an async function that reads HTTP request cookies in Server Components" |
| "You can conveniently access..." | "Returns an object containing..." |
| "The best way to handle navigation" | "<Link> extends the HTML <a> element to provide prefetching and client-side navigation" |
test/ for tests exercising the API to find real usage patterns, edge cases, and expected behavior.switcher/filename usage, tables vs subsections, "Good to know" format, no em dashes, mechanical language.Read these pages in docs/01-app/03-api-reference/ before writing. They demonstrate the patterns above.
04-functions/cookies.mdx - Function with methods table, options table, and behavior notes03-file-conventions/page.mdx - File convention with props subsections and route/URL/value tables02-components/link.mdx - Component with props summary table and detailed per-prop docs01-directives/use-client.mdx - Directive with usage section and serialization rules04-functions/fetch.mdx - Function with troubleshooting section and version historyWeekly Installs
108
Repository
GitHub Stars
138.5K
First Seen
11 days ago
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode103
gemini-cli102
codex102
cursor102
github-copilot102
amp101
lark-cli 共享规则:飞书资源操作指南与权限配置详解
32,800 周安装
Build工作流编排器:AI驱动的开发流程自动化工具,支持绿地/棕地/TDD/重构
239 周安装
设计模式实现指南:TypeScript/JavaScript 代码架构最佳实践与SOLID原则
238 周安装
aixyz on OpenClaw:无需编码部署可收费AI代理的完整指南
237 周安装
Prompt Guard v3.5.0 - 100%离线AI智能体运行时安全防护,内置600+检测模式
238 周安装
Julia编程专家指南:多重分派、类型系统与高性能计算最佳实践
89 周安装
fal.ai AI图像视频生成技能:使用先进AI模型一键生成图像和视频内容
241 周安装
## Usagenext.config.ts snippet. Use subsections for each behavioral aspect.### Example Name subsections. Each example solves one specific use case./docs/app/... format.