next.js icon indicating copy to clipboard operation
next.js copied to clipboard

`useRouter` returns null on the server when using "experimental-edge" runtime

Open remorses opened this issue 3 years ago • 2 comments

Verify canary release

  • [X] I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: darwin
      Arch: x64
      Version: Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64
    Binaries:
      Node: 16.16.0
      npm: 8.14.0
      Yarn: 1.22.17
      pnpm: 7.9.5
    Relevant packages:
      next: 13.0.0
      eslint-config-next: 12.3.0
      react: 18.2.0
      react-dom: 18.2.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

useRouter returns null on the server

Expected Behavior

useRouter should return the router both on server and client

Link to reproduction

https://github.com/remorses/try-next-getserversideprops-edge

To Reproduce

next dev
# visit index page
# router will be null in server logs

remorses avatar Oct 26 '22 10:10 remorses

This seems like a follow-up to https://github.com/vercel/next.js/pull/41714 and https://github.com/vercel/next.js/issues/41713, linking for visibility.

balazsorban44 avatar Oct 26 '22 18:10 balazsorban44

Affects me too

cheesycod avatar Nov 07 '22 17:11 cheesycod

Is anyone working on this issue?

remorses avatar Dec 06 '22 15:12 remorses

Nope, vercel has given up on a usable edge runtime it seems, what a shame...

cheesycod avatar Dec 08 '22 10:12 cheesycod

@remorses can you try the latest next? it should be already fixed by #43302 and #43192. I tested your reproduction locally it works well.

huozhi avatar Dec 12 '22 16:12 huozhi

I confirm it's fixed in canary 🥳

remorses avatar Dec 12 '22 16:12 remorses

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

github-actions[bot] avatar Jan 12 '23 00:01 github-actions[bot]