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

next-navigation(useRouter().push("/url")) does not redirect to /url if server actions is used immediately after useRouter().push("/url") #65287

Closed
ehsanrezaeee opened this issue May 2, 2024 · 3 comments
Labels
bug Issue was opened via the bug report template. locked Navigation Related to Next.js linking (e.g., <Link>) and navigation.

Comments

@ehsanrezaeee
Copy link

Link to the code that reproduces this issue

https://github.com/ehsanrezaeee/next-router-report

To Reproduce

  1. clone the github repo
  2. npm i
  3. run the project in dev mode
  4. type something in the input box to make api call and hit the submit button
  5. wait for the router to redirect to different url
  6. url changes but it wont redirect

Current vs. Expected behavior

i expected to redirect to the specific url but instead the url changed and the redirection didnt happen

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 32581
  Available CPU cores: 12
Binaries:
  Node: 20.10.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.2.3 // Latest available version is detected (14.2.3).
  eslint-config-next: 14.2.3
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.4.5
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Navigation

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local), Other (Deployed)

Additional context

i tested the application on the production and still having issues i mentioned. i didnt test on the canary latest version.

@ehsanrezaeee ehsanrezaeee added the bug Issue was opened via the bug report template. label May 2, 2024
@github-actions github-actions bot added the Navigation Related to Next.js linking (e.g., <Link>) and navigation. label May 2, 2024
@samcx
Copy link
Member

samcx commented May 5, 2024

Hi @ehsanrezaeee, this is due to action queuing and is expected. The action might return a revalidate payload so the client needs to wait. We recommend using revalidatePath/redirect instead of router.push, which will also save another round trip to the server.

@samcx samcx closed this as completed May 5, 2024
@ehsanrezaeee
Copy link
Author

Thanks for explaining the issue.

Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. locked Navigation Related to Next.js linking (e.g., <Link>) and navigation.
Projects
None yet
Development

No branches or pull requests

2 participants