# How to use the query string params in react?

**URL:** <https://forum.freecodecamp.org/t/how-to-use-the-query-string-params-in-react/482515>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [October 20, 2021, 6:47pm UTC](https://forum.freecodecamp.org/t/how-to-use-the-query-string-params-in-react/482515 "2021-10-20T18:47:46Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![lingo1357](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lingo1357/32/183540_2.png) [@lingo1357](https://forum.freecodecamp.org/u/lingo1357)\
**Post date:** [October 20, 2021, 6:47pm UTC](https://forum.freecodecamp.org/t/how-to-use-the-query-string-params-in-react/482515/1 "2021-10-20T18:47:46Z")

</div>

Hello,

How to use the query string params in react?

regards,

---

<div class="post-metadata">

**Author:** ![lasjorg](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lasjorg/32/280761_2.png) [@lasjorg](https://forum.freecodecamp.org/u/lasjorg)\
**Post date:** [October 20, 2021, 6:59pm UTC](https://forum.freecodecamp.org/t/how-to-use-the-query-string-params-in-react/482515/2 "2021-10-20T18:59:18Z")

</div>

You may want to expand the context of the question.  
What are you trying to do exactly?

> [@How Transmit information from one page to another thanks to the parameters contained in the url](https://forum.freecodecamp.org/t/how-transmit-information-from-one-page-to-another-thanks-to-the-parameters-contained-in-the-url/479200/2):
>
> You can use [URLSearchParams](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) and window.location.search 
> 
> > **Example**
> >
> > First page link: \<a href="./second.html?product=coffee&productId=abc123"\>Coffee\</a\> Second page JS const params = new URLSearchParams(window.location.search); const product = params.get('product'); const productId = params.get('productId');
> 
> Just be mindful about what you encode into the URL and how you use it. You can’t trust user input and the URL can be altered.

---

<div class="post-metadata">

**Author:** ![lingo1357](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lingo1357/32/183540_2.png) [@lingo1357](https://forum.freecodecamp.org/u/lingo1357)\
**Post date:** [October 20, 2021, 7:32pm UTC](https://forum.freecodecamp.org/t/how-to-use-the-query-string-params-in-react/482515/3 "2021-10-20T19:32:23Z")

</div>

> [@lasjorg](#):
>
> You may want to expand the context of the question.  
> What are you trying to do exactly?

I don’t want to expand the question. I expand my project.  
Formerly I was using the query string in [ASP.net](http://ASP.net) webForm but now I have forgotten how the param is used.

---

<div class="post-metadata">

**Author:** ![lasjorg](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lasjorg/32/280761_2.png) [@lasjorg](https://forum.freecodecamp.org/u/lasjorg)\
**Post date:** [October 20, 2021, 7:35pm UTC](https://forum.freecodecamp.org/t/how-to-use-the-query-string-params-in-react/482515/4 "2021-10-20T19:35:48Z")

</div>

> [@lingo1357](#):
>
> I don’t want to expand the question. I expand my project.

I mean you will have to give us more detail about what you are trying to achieve.

That is what I mean by context. Taken out of context your question is hard to understand and give an answer to.

---

<div class="post-metadata">

**Author:** ![lingo1357](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lingo1357/32/183540_2.png) [@lingo1357](https://forum.freecodecamp.org/u/lingo1357)\
**Post date:** [October 20, 2021, 8:35pm UTC](https://forum.freecodecamp.org/t/how-to-use-the-query-string-params-in-react/482515/5 "2021-10-20T20:35:54Z")

</div>

I want to make an app for upload and editing and creating image.  
of course the editor is a component.

---

<div class="post-metadata">

**Author:** ![lasjorg](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lasjorg/32/280761_2.png) [@lasjorg](https://forum.freecodecamp.org/u/lasjorg)\
**Post date:** [October 20, 2021, 10:02pm UTC](https://forum.freecodecamp.org/t/how-to-use-the-query-string-params-in-react/482515/6 "2021-10-20T22:02:48Z")

</div>

You didn’t answer the question, what is it you are trying to do?

> [@lingo1357](#):
>
> How to use the query string params in react?

Why and for what?

If you can’t answer that it’s a lot harder to help you. Was the link I posted of any help?

---

<div class="post-metadata">

**Author:** ![DanCouper](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/dancouper/32/158608_2.png) [@DanCouper](https://forum.freecodecamp.org/u/DanCouper)\
**Post date:** [October 20, 2021, 10:07pm UTC](https://forum.freecodecamp.org/t/how-to-use-the-query-string-params-in-react/482515/7 "2021-10-20T22:07:35Z")

</div>

Yes, it’s very difficult to understand what you do or don’t know here, never mind purpose.

If you _do_ understand what query params are and you’re just trying to construct/parse them, and it’s a web app, then the browser [has an API for working with URLs that does this](https://developer.mozilla.org/en-US/docs/Web/API/URL)

---

<div class="post-metadata">

**Author:** ![lingo1357](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lingo1357/32/183540_2.png) [@lingo1357](https://forum.freecodecamp.org/u/lingo1357)\
**Post date:** [October 20, 2021, 10:10pm UTC](https://forum.freecodecamp.org/t/how-to-use-the-query-string-params-in-react/482515/8 "2021-10-20T22:10:24Z")

</div>

> [@lasjorg](#):
>
> If you can’t answer that it’s a lot harder to help you. Was the link I posted of any help?

> I want to make an app for upload and editing and creating images.  
> of course, the editor is a component.

But I answered your question!  
I’m working on it.

---

<div class="post-metadata">

**Author:** ![lingo1357](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lingo1357/32/183540_2.png) [@lingo1357](https://forum.freecodecamp.org/u/lingo1357)\
**Post date:** [October 20, 2021, 10:12pm UTC](https://forum.freecodecamp.org/t/how-to-use-the-query-string-params-in-react/482515/9 "2021-10-20T22:12:45Z")

</div>

> [@DanCouper](#):
>
> If you _do_ understand what query params are and you’re just trying to construct/parse them, and it’s a web app, then the browser [has an API for working with URLs that does this](https://developer.mozilla.org/en-US/docs/Web/API/URL)

I was just reading and googly-related tutorials.  
I have worked with query params in [ASP.net](http://ASP.net) webform but have forgotten how to use params.

Thanks for the API.

**I think the way I asked the question makes it hard to reader understand what is in my mind. So I changed the subject. But my English is poor, so this is natural.**

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [April 21, 2022, 10:12am UTC](https://forum.freecodecamp.org/t/how-to-use-the-query-string-params-in-react/482515/10 "2022-04-21T10:12:48Z")

</div>

Closed on April 21, 2022, 10:12am UTC

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
