Skip to content

Error <Html> should not be imported outside of pages/_document and experimental-edge #52158

@rbox-risk

Description

@rbox-risk

Verify canary release

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

Provide environment information

Operating System:
      Platform: win32
      Arch: x64
      Version: Windows 10 Pro
    Binaries:
      Node: 18.16.0
      npm: N/A
      Yarn: N/A
      pnpm: N/A
    Relevant Packages:
      next: 13.4.8
      eslint-config-next: 13.4.8
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.6
    Next.js Config:
      output: N/A

Which area(s) of Next.js are affected? (leave empty if unsure)

Middleware / Edge (API routes, runtime)

Link to the code that reproduces this issue or a replay of the bug

https://github.com/rbox-risk/testedge

To Reproduce

When using:
-pages directory
and
-custom _document
and
switching to the experimental edge rendering runtime using the value exported from the page
export const runtime = "experimental-edge"

results in the error
[Error: <Html> should not be imported outside of pages/_document. Read more: https://nextjs.org/docs/messages/no-document-import-in-page]

image

reverting to [email protected] disappears the error

Describe the Bug

Bug appears to be related to experimental edge rendering runtime

Expected Behavior

minimal page example should render either nodejs or edge depending upon the rendering runtime.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    RuntimeRelated to Node.js or Edge Runtime with Next.js.lockedplease add a complete reproductionPlease add a complete reproduction.staleThe issue has not seen recent activity.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions