Next.js Discord

Discord Forum

Router.push('/page'), re-render

Answered
Elm sawfly posted this in #help-forum
Open in Discord
Elm sawflyOP
Is there any way to push to a page without without re-fetching all the data. I am trying to go to '/report/reportid/expense/expenseid' and just update the id of the expense without re-fetching the list of expenses. because i fetched them initially.
Answered by Ray
 window.history.pushState(null, '', '/report/reportid/expense/expenseid')
View full answer

7 Replies

Answer
Elm sawflyOP
🐐
@Ray ts window.history.pushState(null, '', '/report/reportid/expense/expenseid')
Asiatic Lion
I have the case where I send the user back with params and it loses state
that when I use router.push, if I use window.history next can't react to that
so i'm forced to use push and lose state of the navbar
in dev it works great, it will keep state but in prod it won't :thinq: