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
Asked
Active
Viewed 162 times
-2
-
1SO is not a coaching site. – shaedrich Apr 09 '21 at 12:03
-
What exactly is not working as expected? Can you provide some code and clarify what the issue is? – juliomalves Apr 09 '21 at 13:12
2 Answers
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

Rowin
- 206
- 2
- 6
-
Thank you. I understood routing but shallow routing not working as i expected. in my project – Tuvshuu Erdenebileg Apr 09 '21 at 11:46
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