Next.js Discord

Discord Forum

Why Does revalidatePath('/users') Automatically Update User Data on the Same Page in Next.js?

Unanswered
American posted this in #help-forum
Open in Discord
AmericanOP
In my Next.js app, I have a server component that fetches user data using an API call and renders a client component. Inside the client component, I perform a mutation via a server action to update the user data (e.g., adding or modifying a user), and after the mutation, I call revalidatePath('/users'). Why does the page display the updated user data immediately without requiring me to navigate away or manually refresh, even though I remain on the same /users page?
in the docs its saying that revalidatePath only invalidates the cache when the included path is next visited.
have i got it wrong ?

2 Replies

^^ What he said, Server Actions return the fresh data + the new RSC payload of the updated UI in a single roundtrip

What you mentioned the docs say about revalidatePath, applies for the cases where you trigger a revalidation outside of a Server Action and for the paths/tags you’re not currently on.