title: Want to have an event handler for the browser's back button with next.js
body: <p>I am having a modal which while opening pushes a hash to url <code>example.com/#modal</code>, on browser back button click, I want to recognise that event so that I can toggle the state of modal. the point is, since Im using it with next.js (server side rendering), I will not be having access to window object (correct me if I am wrong). so I need an alternate way to handle the event of browser back button.</p>