Skip to content

Instantly share code, notes, and snippets.

View ariefurtado's full-sized avatar

Arie Gomes Furtado ariefurtado

View GitHub Profile
@ariefurtado
ariefurtado / force-full-page-reload.ts
Last active June 23, 2023 18:47
This snippet is useful to force nextjs to do a full page reload.
/**
* Whenever you're working with web-components and nextjs in development mode, it is possible that the "Fast Refresh" feature
* of nextjs don't re-render your web-component. It's a little bit stressful that you have to reload the page manually every time
* you update something. (thats why we have HMR and nextsjs Fast Refresh)
*
* For anyone in need of a way to force the full page reload whenever the "Fast Refresh" occurs, I've made a simple snippet that
* uses nextjs internal websocket to listen for that.
*
* One potential downside to this approach is that it relies on internal functionality of Next.js,
* which could potentially change in future versions and break your code. However, as long as you're