Next.js Discord

Discord Forum

Preserve the value of a variable after navigating to another page

Unanswered
Virginia's Warbler posted this in #help-forum
Open in Discord
Virginia's WarblerOP
Situation: 3 pages: A, B and C
From A, you can navigate to B or C.
When I come back to A from B, it passes a param back to A, lets call it x.
And then I come back to A from B, the value of x is gone.
What's the best way to preserve the value of x?

3 Replies

Transvaal lion
Use url search params
Virginia's WarblerOP
Other than that? Any other way? Passing things back and forth can become messy
@Virginia's Warbler Other than that? Any other way? Passing things back and forth can become messy
Transvaal lion
You can use the nuqs library to help with the "messiness" or probably wrap the pages in a context 🤔