Is there any way i can use or have access to nextRouter/history in nextjs getInitialProps
function.
const ViewPost: NextPage<EditPostProps> = (props): React.ReactElement<void> => {
const router = useRouter(); // works here
}
ViewPost.getInitialProps = async (ctx: Context): Promise<EditPostProps> => {
const router = useRouter(); // doesn't work
// ctx props doesn't have history
}
export default withRouter(ViewPost);
My api class receives history or router as a param hence the need for one, but i couldn't get access to one inside the getInitialProps. Pls is there anyway i can access it? Any help would be appreciated.