Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nextjs): Fix router compat when use client is used #7951

Merged
merged 1 commit into from
Mar 18, 2025

Conversation

desiprisg
Copy link
Contributor

@desiprisg desiprisg commented Mar 18, 2025

What changed? Why was the change needed?

Problem: An error seems to be thrown when using app directory and use client in the file that contains the Inbox.
I'm guessing this happens because use client causes our pages implementation to be used.
This means that it needs to be adaptive. We cannot execute useRouter from next/navigation in pages router and we cannot execute useRouter from next/router in app router.
We can have a InboxCommonProvider that will useRouter from next/compat/router. If that succeeds (it will be the next/router), it means that we are ok. If it fails, it means that the pages router could not be used and we should useRouter from next/navigation instead.

Screenshots

Expand for optional sections

Related enterprise PR

Special notes for your reviewer

Copy link

netlify bot commented Mar 18, 2025

Deploy Preview for dashboard-v2-novu-staging canceled.

Name Link
🔨 Latest commit 4806171
🔍 Latest deploy log https://app.netlify.com/sites/dashboard-v2-novu-staging/deploys/67d9bb1703de510008deb4b7

Copy link

pkg-pr-new bot commented Mar 18, 2025

Open in Stackblitz

npm i https://pkg.pr.new/novuhq/novu/@novu/nextjs@7951
npm i https://pkg.pr.new/novuhq/novu@7951

commit: 4806171

@SokratisVidros SokratisVidros merged commit ad7e01a into next Mar 18, 2025
23 of 26 checks passed
@SokratisVidros SokratisVidros deleted the fix_app_router_use_client branch March 18, 2025 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants