Home
Support Forums

Query params not rendering on page

https://apsum.netlify.app/

I am using Gatsby and React for a website.

I want to display the query params from the URL on the page. I have something like:

const IndexPage () => {
     const params = new URLSearchParams(location.search);
     const DOI = params.get("doi");

     return (
          <div>{DOI}</div>
     )
}

where the URL is https://apsum.netlify.app/?doi=123, for example.

I want 123 to display on the page, but it is not.

I had a redirect in my netlify.toml file.

Commenting this out solved the problem.

1 Like