Next.js Discord

Discord Forum

Passing data between pages in /app

Unanswered
Rex posted this in #help-forum
Open in Discord
RexOP
Do you know how to pass data between routes in /app?
Because I wanted to use a <Link> component to jump to another page, passing data to that, is it possible?

16 Replies

@@ts-ignore you can use internal state or use query params
RexOP
I tried passing an object with Link using the query param, but then when I try to retrieve the object from the other page, I get undefined (accessing to it by UseSearchParams())
@@ts-ignore can I see the code where you call that hook
RexOP
I tried these 2 solutions, but none of them worked
This is the first page
are you using pages router or app router?
RexOP
app router
I have /app/pages
the second one should work
can you create a minimal reproduction repo
@@ts-ignore the second one should work
RexOP
I saw on stackoverflow that in app router they uses router to push, so can I use it also to pass data between pages instead of LInk?
@@ts-ignore you can try it
RexOP
Or, do you think localstorage could be a good solution to this?
you can also use that but I won't recommend it