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

Remove unnecessary router.refresh() usage #9

Merged
merged 2 commits into from
Jul 19, 2023

Conversation

karlhorky
Copy link
Member

@karlhorky karlhorky commented Jul 1, 2023

Since Next.js 13.4.6, calling cookies().set() in a Server Action invalidates the client cache:

This means that we no longer need to call router.refresh() anymore, which means we can:

  • remove the router.refresh() in the logout button Client Component and remove the logout Client Component
  • remove the router.refresh() in the FruitCommentForm Client Component

Since Next.js 13.4.6, calling `cookies().set()` in a Server Action invalidates
the client cache:

- vercel/next.js#42991 (comment)
- PR vercel/next.js#51290

This means that we no longer need the Client Component, because we do not need
to call router.refresh() anymore.
@karlhorky karlhorky requested a review from Josehower July 1, 2023 13:39
@karlhorky karlhorky changed the title Remove unnecessary logout Client Component Remove unnecessary router.refresh() usage Jul 1, 2023
Copy link
Contributor

@Josehower Josehower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

scheduled to merge on 18th

@karlhorky karlhorky merged commit 14c9f4e into main Jul 19, 2023
3 checks passed
@karlhorky karlhorky deleted the remove-logout-client-component branch July 19, 2023 09:32
@ProchaLu
Copy link
Member

ProchaLu commented Jul 27, 2023

we found an issue with this: cookies().set(...) no longer clears the client cache starting in next@13.4.11-canary.1 :

@karlhorky
Copy link
Member Author

@ProchaLu
Copy link
Member

Upgraded my test project and tested cookie(set) and cookie(get) again. Everything works as expected now without refreshing the page.

Screen.Recording.2023-09-14.at.13.35.42.mov

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

Successfully merging this pull request may close these issues.

None yet

3 participants