Introducing "Redocusaurus": Redoc for Docusaurus

Redocusaurus

npm version npm downloads

What is it?

It is a preset for docusaurus, with 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?

  1. Install the preset

    npm i --save redocusaurus
    
  2. Add it to your docusaurus.config.js:

    module.exports = {
     // ...
     presets: [
       [
         "redocusaurus",
         {
           specs: [
             {
               routePath: "/api/",
               specUrl: "https://redocly.github.io/redoc/openapi.yaml",
             },
           ],
         },
       ],
     ],
     // ...
    };
    
  3. 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.

API Icon by mikicon from the Noun Project

Source

You can find the source on Github:

redocusaurus