I created a wrapper for the pages which will bounce unauthenticated users to the login page. PrivateRoute Wrapper: import { useRouter } from 'next/router' import { useUser } from '../../lib/hooks' import Login from '../../pages/login' const withAuth = Component => { const Auth = (props) => { const { user } = useUser(); const router = useRouter(); if (user === null && typeof window !== 'undefined') { return ( <Login /> ); } return ( <Component...
Originally asked by Antonio Pavicevac-Ortiz on Stack Exchange (stackoverflow) (CC BY-SA 4.0).