Search code examples
javascriptdocusaurus

Add optional parameters to URL of Docusaurus websites


I have a website built using Docusaurus 2.

I'm wondering if it is possible to add optional parameters to the URL of the site. For example, I may want to have https://www.example.com/docs/introduction?param=abc, then I will use the value of param in my components.

Is it feasible in Docusaurus?


Solution

  • Not sure if I'm understand your question, but I don't see why not. Having query params wouldn't change the URL, you just need to use window.location.search and parse the params, or use React Router's APIs to do it for you.