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

Compatibility with next intl #9

Open
spaquis opened this issue Nov 17, 2024 · 3 comments
Open

Compatibility with next intl #9

spaquis opened this issue Nov 17, 2024 · 3 comments

Comments

@spaquis
Copy link

spaquis commented Nov 17, 2024

Hey,
Thank you for your work on this subject.

I have a screen where I put the navigation guard, it works perfectly. But on this screen you can change the language of the application.
To do this, I use nextIntl with this:
router.push(${pathName}?${searchParams.toString()}, { locale: lang });

My strategy was to disable the guard before calling router.push and then re-enable it afterwards (the enableGuard state is placed in a context that wraps the whole page).
The problem is that after pushing the new router with the locale changes, the guard no longer works.

Can you help me.
Regards,

@ypresto
Copy link
Collaborator

ypresto commented Nov 19, 2024

Thank you for reporting!

It might be interfering with next-intl itself, as it seems creating custom router too.

Can you provide a reproduction repo? 🙏

@riccardolardi
Copy link

Also looking for a solution to allow usage with next-intl. If it was possible to check whether the router pathname change is a locale change or not and use that to bypass the navigation guard would work?

@ypresto
Copy link
Collaborator

ypresto commented Dec 11, 2024

bypass the navigation guard would work?

It does not work because our history intervention is to add index of history stack, so it is always active despite of enabled/disabled of the guard.

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

No branches or pull requests

3 participants