Installation
Quick Start
1. Configure Styles
Add the OpenAPI preset to your CSS:app/global.css
2. Create OpenAPI Instance
Create a server-side OpenAPI instance with your schema:lib/openapi.ts
lib/openapi.ts
3. Create API Page Component
components/api-page.tsx
components/api-page.client.tsx
Generating Documentation
Option 1: Generate MDX Files
Generate static MDX files from your OpenAPI schema:scripts/generate-docs.ts
APIPage component to your MDX components:
mdx-components.tsx
Option 2: Virtual Files
Generate pages dynamically without creating files:lib/source.ts
app/docs/[[...slug]]/page.tsx
Generation Options
File Organization
Control how pages are generated:per Option | Description | File Path |
|---|---|---|
operation | One page per endpoint | {operationId}.mdx |
tag | Group by OpenAPI tag | {tag_name}.mdx |
file | One page per schema file | {file_name}.mdx |
custom | Custom function | Define your own |
groupBy Option | Output |
|---|---|
none (default) | {operationId}.mdx |
tag | {tag}/{operationId}.mdx |
route | {endpoint_path}/{method}.mdx |
Index Pages
Generate index pages with cards:Frontmatter Customization
Features
Interactive API Playground
Every endpoint includes an interactive playground where users can:- Test API endpoints directly from documentation
- Modify request parameters and body
- View real-time responses
- Try different authentication methods
Code Generation
Automatic code examples in multiple languages:- cURL
- JavaScript/TypeScript
- Python
- Go
- Java
- C#
components/api-page.client.tsx
Type-Safe Schemas
Automatic TypeScript types from JSON schemas with:- Request parameters
- Request body types
- Response types
- Enum values
Response Samples
Display example responses with syntax highlighting:lib/openapi.ts
Server API
createOpenAPI
Create an OpenAPI server instance:Methods
Advanced Configuration
Custom Transformations
Imports
Add custom imports to generated files:Best Practices
- Use operation IDs: Define unique
operationIdfor each endpoint in your OpenAPI spec - Add descriptions: Include detailed descriptions for endpoints, parameters, and responses
- Enable caching: Use the default caching to improve build times
- Group logically: Use tags to organize endpoints into logical groups
- Add examples: Include request/response examples in your OpenAPI schema