Skip to content
Advertisement

Getting URL Parameters on GatsbyJS

Is there a way to retrieve url parameters passed on pages of project built on GatsbyJS? I’m trying to implement a password reset function on my page using AWS, but they can only send the parameters through a link sent to the user’s email.

So the flow would be like this :

User triggers Forgot Password -> AWS sends email to user with link -> Link directs to my page with the parameters -> Reset password form automatically populates fields with the parameters passed

Update

Here’s my App.js code :

JavaScript

Reset.js :

JavaScript

Advertisement

Answer

Use URLSearchParams.get() as described on MDN:

JavaScript

Alternative: package query-string

yarn add query-string or npm i --save query-string

JavaScript
Advertisement