window is not defined Next Js
if (typeof window !== 'undefined') { // Boom }
Next js window is not defined solution
var currentUrl = ''; if (typeof window !== 'undefined') { currentUrl = window.location.href; } if (typeof window !== 'undefined') { window.onload = function afterWebPageLoad() { setLoading(false); } } setTimeout(function () { setLoading(false); }, 30000);
Source: techloset-dev.vercel.app