Uh oh!
There was an error while loading. Please reload this page.
fix(nextjs): Replace router.refresh() with cookies().delete() - #3518
Conversation
🦋 Changeset detectedLatest commit: df967c2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Hi @nikosdouvlis, |
desiprisg
commented
Jun 7, 2024
!snapshot |
clerk-cookie
commented
Jun 7, 2024
Hey @desiprisg - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/backend@1.2.2-snapshot.v958fab4 --save-exact
npm i @clerk/chrome-extension@1.0.17-snapshot.v958fab4 --save-exact
npm i @clerk/clerk-js@5.6.0-snapshot.v958fab4 --save-exact
npm i @clerk/elements@0.6.0-snapshot.v958fab4 --save-exact
npm i @clerk/clerk-expo@1.2.0-snapshot.v958fab4 --save-exact
npm i @clerk/express@0.0.11-snapshot.v958fab4 --save-exact
npm i @clerk/fastify@1.0.13-snapshot.v958fab4 --save-exact
npm i gatsby-plugin-clerk@5.0.0-beta.45 --save-exact
npm i @clerk/localizations@2.4.4-snapshot.v958fab4 --save-exact
npm i @clerk/nextjs@5.1.4-snapshot.v958fab4 --save-exact
npm i @clerk/clerk-react@5.2.3-snapshot.v958fab4 --save-exact
npm i @clerk/remix@4.1.0-snapshot.v958fab4 --save-exact
npm i @clerk/clerk-sdk-node@5.0.10-snapshot.v958fab4 --save-exact
npm i @clerk/shared@2.2.2-snapshot.v958fab4 --save-exact
npm i @clerk/testing@1.1.6-snapshot.v958fab4 --save-exact
npm i @clerk/themes@2.1.9-snapshot.v958fab4 --save-exact
npm i @clerk/types@4.6.0-snapshot.v958fab4 --save-exact |
nikosdouvlis
commented
Jun 7, 2024
Hello @joysamaddar , I hope you're having a great day as well :) Would you mind sharing a GH issue that describes your problem in detail, if there is one? Happy to take a look. |
Hello again, |
3d30933 to
185c4b3CompareUh oh!
There was an error while loading. Please reload this page.
ab98df2 to
f17124aCompare
desiprisg
left a comment
There was a problem hiding this comment.
Good job on that conditional check
Description
In this PR we replace
router.refreshwith a server action that callscookies().delete. According to the NextJS docs, using thecookies().deleteAPI invalidates the FE client cache, similar to whatrouter.refreshdoes.The main difference between the two is that
router.refreshwill then attempt to fetch and re-mount the current page. This causes our components to unmount and mount again, losing state beforesetActivecompletes. This usually leads to navigation/redirect issues, issues completing oauth flows etc.Caveat:
We can only use server action directly for next@14 and above, as server actions were an experimental feature in next@13.
For next@13 we still call
router.refresh. Users that are on next@13 should upgrade to at leastnext@14if they notice any of the issues described above.Checklist
npm testruns as expected.npm run buildruns as expected.Type of change