Why store router on zustand if router is already available via useRouter?
See original GitHub issueI’m curious about what’s the advantage / goal of storing router on zustand if it’s already available via useRouter ?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:5 (3 by maintainers)
Top Results From Across the Web
import Router from 'next/router' is it ok? - Stack Overflow
I guess the main suggestion to not use Router.push() or Router.pathname directly from the object itself is because of the way Next.js serves ......
Read more >Why does React re-render the components multiple times ...
I've minimized unnecessary re-renders by using this approach: const setLoading = useStore.getState().setLoading or something like that. You'd ...
Read more >next/router | Next.js
useRouter is a React Hook, meaning it cannot be used with classes. You can either use withRouter or wrap your class in a...
Read more >How to build a route progress bar in Next.js - Skillthrive
Create a progress bar at the top of a Next.js application to let users know ... file is where you'll create the store...
Read more >Using Zustand in Your Next React Project - This Dot Labs
This article, we will focus more on the practical use of Zustand in a ... @emotion/react @emotion/styled react-icons react-router-dom axios ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

If you just import “Router” directly instead of “useRouter” won’t that fix the issues?
i.e.
Hello!
It is because context is lost through the reconciler. So we have to either way forward it through context bridge or via a state manager such as Zustand.
If that answers your question feel free to close this issue. Maybe we could add a small explanation in the readme