Skip to content

How do I refresh the page in next.js 14 app router? #62146

Answered by icyJoseph
qjrjsel asked this question in App Router
Discussion options

You must be logged in to vote

It is perfectly fine to use window.location.reload.

As for the router.refresh method, let's look at the docs, https://nextjs.org/docs/app/api-reference/functions/use-router#userouter:

router.refresh(): Refresh the current route. Making a new request to the server, re-fetching data requests, and re-rendering Server Components. The client will merge the updated React Server Component payload without losing unaffected client-side React (e.g. useState) or browser state (e.g. scroll position).

and from, https://nextjs.org/docs/app/building-your-application/caching#routerrefresh:

The refresh option of the useRouter hook can be used to manually refresh a route. This completely clears the Rout…

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
4 replies
@kasir-barati
Comment options

@emporteme
Comment options

@emporteme
Comment options

@ronny1020
Comment options

Answer selected by qjrjsel
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@martinharyanto
Comment options

@shubhamkashyapdev
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
9 participants