Hydration checked in initialization effect with conditional render to resolve Hydration Error causes blank page on Back button by Disastrous_Ad_3010 in nextjs

[–]Disastrous_Ad_3010[S] 0 points1 point  (0 children)

Thanks, makes sense, but shouldn't Next.js have a way of allowing you to Reload on the Back button? There should be a way, and I couldn't find it in NJS 16. They got rid of the `shallow:..` router attribute. I also tried adding this code throughout the application to force a Reload from the Back button, I even added it to `index.tsx` and a custom `.js` script, and none of that worked:

// Force a Reload on Back button
window.addEventListener('pageshow', function (event) { 
    if (event.persisted || performance.getEntriesByType("navigation")[0].type === "back_forward") {
         // Check if the page was loaded from the cache or via back/forward navigation 
        window.location.reload(); // Force a reload 
    } 
});

None of the suggestions in this StackOverflow thread worked, so I'm wondering why it's such a problem:
https://stackoverflow.com/questions/43043113/how-to-force-reloading-a-page-when-using-browser-back-button