El estado cambia al cambiar la ruta Usecontext a continuación

//If the user refreshes the page the app reset so you will lose any state yes,
//to navigate to different pages without refreshing the page you have to use the 
//Link component from next/link (or react-router-dom if using React), if you want to preserve the user state
//between refreshes you can save it to the localStorage
Grieving Gharial