Next.js Discord

Discord Forum

Refresh router + redirect, show new data after browser back

Unanswered
TSnerd posted this in #help-forum
Open in Discord
I have a modal that adds a row to a table on a certain page. The button in the modal makes an API call and adds the item to the database. I then call router.refresh() to get the new data from the server, and this populates on the page. I then tried to add a redirect to the newly created item's page using router.push() which works, but then when clicking the browser back button, I am presented with the old page with the old data. What is the correct way to update this first page with the new data at the same time as redirecting to the new page?

0 Replies