A lightweight Express middleware that mounts interactive ReDoc documentation from your OpenAPI/Swagger spec. Zero config, full TypeScript support, CSP-friendly.
npm install redoc-express
Minimal overhead, zero config, fully customizable. Just mount and go.
Serves a static HTML shell that pulls your spec at runtime. Zero overhead.
Complete type definitions and modern TS-friendly API out of the box.
136 comprehensive test cases with full code coverage and daily CI runs.
Drop-in middleware with sensible defaults. Customize only what you need.
Built-in nonce support for strict Content Security Policies.
Supports OpenAPI 3.x and Swagger 2.0 specifications.
Install the package
Using npm, yarn, or pnpm
Serve your OpenAPI/Swagger spec
As JSON from any endpoint
Mount the middleware
Point it to your spec URL
const express = require('express');
const redoc = require('redoc-express');
const app = express();
const port = 3000;
// Serve your OpenAPI/Swagger spec
app.get('/docs/swagger.json', (req, res) => {
res.sendFile('swagger.json', { root: '.' });
});
// Mount ReDoc middleware
app.get('/docs', redoc({
title: 'API Documentation',
specUrl: '/docs/swagger.json'
}));
app.listen(port, () => {
console.log(`📚 Docs at http://localhost:${port}/docs`);
});
Comprehensive test suite with 136 test cases and 100% code coverage.
Code Coverage
Test Cases
Execution Time
Lint Errors
Customize theme, behavior, and more with ReDoc options
app.get('/docs', redoc({
title: 'My API Documentation',
specUrl: 'https://api.example.com/openapi.json',
nonce: 'random-nonce-123', // Optional: CSP compliance
redocOptions: {
theme: {
colors: { primary: { main: '#6EC5AB' } },
typography: {
fontFamily: '"Inter", sans-serif',
fontSize: '15px'
}
},
hideDownloadButton: true,
expandResponses: '200,201'
}
}));
.d.ts files).