reactjsurlgatsbyquery-stringquerystringparameter

How to work (get, set) with query string in a url using react or Gatsby (whitout window || document)


How to get or set the query string using React or Gatsby (without using document or window objects):

https://link.com/?color=#fff&theme=light

Solution

  • You can use this module for react: https://github.com/pbeshai/use-query-params

    for gatsby, you can use this plugin : https://www.gatsbyjs.com/plugins/gatsby-plugin-use-query-params/ it'll wrap your app with QueryParamProvider