-2

I am beginner in next js.I know how next js routing works but shallow routing not working as i expected in my project. Please share a helpful resources about it except official documentation

2 Answers2

0

I would take a look at this post:

import Router from 'next/router' is it ok?

Here is a similar question about this topic. Otherwise I would really suggest reading the docs of Next.js

https://nextjs.org/docs/api-reference/next/router

Rowin
  • 206
  • 2
  • 6
0

You can try this way.

import { withRouter } from "next/router";
import Router from "next/router";
const ComponentName= ({ router }) => {
//.......
Router.replace(`/`); // here will be location

}
export default withRouter(ComponentName);

if still not work, then try with uesEffect()

  useEffect(() => {

    // you initial function

  }, [router]);
Alamin
  • 1,878
  • 1
  • 14
  • 34