Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: revalidatePath docs should be updated to reflect the current behavior #59214

Closed
tdurnford opened this issue Dec 3, 2023 · 3 comments
Closed
Labels
Documentation Related to Next.js' official documentation. locked

Comments

@tdurnford
Copy link

tdurnford commented Dec 3, 2023

What is the improvement or update you wish to see?

The current revalidatePath documentation suggests that developers can selectively revalidate specific routes. However, as per a GitHub issue comment by @timneutkens, the revalidatePath function currently revalidates the entire client-side router cache, not just individual paths.

This behavior contradicts the documentation's implication that the function allows for granular control over route revalidation. It's important for the documentation to accurately reflect the current capabilities of revalidatePath. Misleading information could lead to confusion and inefficiencies among developers using this function.

I recommend updating the documentation to clarify the current behavior of revalidatePath and to note that future updates are planned to make this feature more granular. Additionally, providing a roadmap or an estimated timeline for when developers can expect the revalidatePath function to support individual path revalidation would be highly beneficial for planning and development purposes.

Is there any context that might help us understand?

The lack of clarity on when the function will support granular revalidation makes it challenging for developers to plan and implement cache strategies effectively. By providing accurate documentation and a roadmap for future updates, developers can better anticipate changes and adapt their strategies accordingly.

Does the docs page already exist? Please link to it.

https://nextjs.org/docs/app/api-reference/functions/revalidatePath

DX-2254

@tdurnford tdurnford added the Documentation Related to Next.js' official documentation. label Dec 3, 2023
@kahnclusions
Copy link

This also needs to cover the several features that are not working as expected per documentation. The recommended way to do forms in modals is with intercepting and parallel routes, but by calling revalidatePath or revalidateTags from a server action causes the client to redirect to the intercepting route's page, control never returns to the submit function. I don't even know a workaround besides "don't use intercepting/parallel routes" for forms.

Everything around these features just seems totally broken and the lack of any response or updates addressing these issues is a bit disappointing.

See #54085

@Vibrat
Copy link

Vibrat commented Jan 11, 2024

The most noticeable effect that I observed is the flash of an entire screen due to hot reload. And to handle granular re-rendering in client, I had to opt out of revalidatePath and revalidateTag and use another full-client-cache query library like react-query (see more: invalidateQueries)

For example, we can wrap server action by a client function that invalidates client query as below.

import { useQueryClient } from '@tanstack/react-query'
import { onServerActionSubmit } from "./actions.ts"

export const MyForm =  () => { 
  const query = useQueryClient()
  async function clientSubmit(e) {
     const serverActionResponse = await onServerActionSubmit()
     if (serverActionResponse == true) {
        query.invalidateQueries({
           queryKey: ["/api/test"]
      })}
  }
  
  return <form onsubmit={clientSubmit}>
  ...
  </form>
}

Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation Related to Next.js' official documentation. locked
Projects
None yet
Development

No branches or pull requests

5 participants