Use window object in Next

if (process.browser) {
    // ...
}