As it depends on the window, don't know how to use it in a next.js app. It was working well previously on my react app.