Skip to content
Discussion options

You must be logged in to vote

The issue got resolved when i use the useHydrateAtoms in my library and exported as hook to the next application. In the next application i used the hook when the router is initialized and passed the router to the hook.

Note: Just want i don't want any state related variable to the apps and want to enclose everything in the library did this stuff. In other case if the store for the app and library is same you can directly use the useHydrateAtoms directly.

Library Code
export const useSetRouter = (initialRouter: Router) => { // useHydrateRouter(initialRouter) useHydrateAtoms([[routerAtom, initialRouter]]); }

NextJs App Code
const router = useRouter(); useSetRouter(router)

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@Bilal-Mubeen
Comment options

@Bilal-Mubeen
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by Bilal-Mubeen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants