Skip to content

Scroll restoration does not work with app router #58899

@nuanyang233

Description

@nuanyang233

Link to the code that reproduces this issue

https://github.com/DimensionDev/mask.social

To Reproduce

My current application uses an app router. However, I found that my application's scrollRestoration doesn't work properly. After I checked the source code, it seems that the page router is storing the positioning of the scroll in session storage, but I see that there is no such code in the app router, instead of the But I don't see any such code in the app router, instead it hasfocusAndScrollRef. Does the app router not support scrollRestoration yet?

Current vs. Expected behavior

scrollRestoration works with the app router.

Verify canary release

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

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 22.2.0: Fri Nov 11 02:03:51 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T6000
Binaries:
  Node: 21.2.0
  npm: 10.2.3
  Yarn: N/A
  pnpm: 8.10.4
Relevant Packages:
  next: 14.0.2
  eslint-config-next: 13.5.2
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: N/A

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

App Router

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue was opened via the bug report template.lockedplease simplify reproductionPlease simplify the reproduction.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions