Passing data from one page to another in Next 13

156 views Asked by At

I have a form, the function which is supposed to happen is generating a Card using the data enetered into the form which will then be printed out. I have figured out the priting part,but I am stuck at getting the data from the form to the card display page. I have done something similar in react, where is used the useNavigate hook and its accompanying state prop to pass around data. Is there something equivalent to that in Next 13?

I have tried out the stuff in the docs ie; using the router from next/router and next/naviagtion but they havent worked out for me

1

There are 1 answers

0
Ahmer Saud On

You can pass data from page to another through query parameters, and consume the data using useSearchParams.

OR

You can lift the state of your page to a higher order component to set and consume the data from both the pages.