Skip to content

Next.js Preview Mode on paths don't work with soft navigation #39949

@mehulmpt

Description

@mehulmpt

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 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T8101
Binaries:
Node: 16.14.2
npm: 8.6.0
Yarn: 1.22.18
pnpm: N/A
Relevant packages:
next: 12.2.5
eslint-config-next: 12.0.4
react: 17.0.2
react-dom: 17.0.2

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

Next.js introduced a new feature of setting preview mode on custom paths. This is great, as it sets the preview cookie for a subset of pages only.
However, this doesn't work with soft navigation to those particular set of pages because Next.js reads the JSON from /_next path for the soft nav part.

Screenshot 2022-08-26 at 12 53 00 AM

Therefore, if my preview mode is set on, say, /learn/vitest path, it would only work on other pages if we do a full page reload while visiting other pages. Otherwise, on soft nav with Link component, it would request the props JSON data from /_next path which would not have the preview mode cookies and hence would not load it in preview mode.

Expected Behavior

Described above

Link to reproduction

N/A

To Reproduce

Described above

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue was opened via the bug report template.lockedstaleThe issue has not seen recent activity.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions