Skip to content
Discussion options

You must be logged in to vote

These three do different jobs, and mixing them up is the usual reason people see stale data.

router.refresh(): A client-side call. It tells Next.js to re-render the current route on the server and merge the result into the page, without wiping client state like form inputs or scroll position.

It does not touch the server's cache. If your page reads cached data, you'll just get the cached data again.

revalidatePath(): Runs on the server, in a Server Action or Route Handler. It says "the cached data for this route is out of date, throw it away." Use it when you know which page needs updating.

revalidateTag(): Same idea, but by label instead of by route. You tag your fetches, then one call i…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@alphadev890
Comment options

Answer selected by alphadev890

This comment was marked as duplicate.

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