DEV Community


OpenAPI for Docusaurus! 📘

rohit_gohri profile image Rohit Gohri Originally published at on ・1 min read

Introducing "Redocusaurus": Redoc for Docusaurus


npm downloads

What is it?

It is a preset that allows you to easily integrate OpenAPI documentation into your docs site made with docusaurus. It has 2 main components:

Using Redoc as a React component, this provides 2 theme components, @theme/ApiDoc and @theme/Redoc. You can use them directly in js pages in Docusaurus.

This creates routes from your OpenAPI files or URLs and renders with the components provided by the theme.

How to set it up?

Install the preset

npm i --save redocusaurus

Enter fullscreen mode Exit fullscreen mode

Add it to your docusaurus.config.js:

module.exports = {
 // ...
 presets: [
       specs: [{
         routePath: '/api/',
         specUrl: '',
 // ...

Enter fullscreen mode Exit fullscreen mode
  1. Rebuild your site and you will have your OpenAPI docs available at the /api/ route.

Extra features over directly using Redoc

The theme includes redoc settings and some custom css to make it match the @docusaurus/classic theme. Along with support for dark mode.

Github Repo

Find the source and know more on Github.

github badge

Discussion (0)

Editor guide