Search code examples
docusaurus

Is there built-in authorization mechanism in docusaurus?


Is there any authorization mechanism in docusaurus? In my case not everyone should have access to the documentation

Skimmed through the official documentaion and couldn't find the answer to my question


Solution

  • As far as I know, now it is not possible. For more details take a look at GitHub issue.

    To quote the part that is relevant to you: "Docusaurus builds a static site. IE the content is exactly the same for all users.

    If you want different content displayed for different user roles, you have to:

    • make that content dynamic for each user: ie render it only on the client side by swizzling React components and fetching your dynamic data yourself, like in any React app)
    • build one different static site per user role, each containing a different set of visible pages. You can use serverless edge functions (Cloudflare Workers for example) to serve one static deployment or another based on the role of the user and pages they can access.

    Remember all these are concerns that are outside the scope of Docusaurus. In the end, we just build a static React site."