Verify 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: 18.12.0
npm: 8.19.2
Yarn: N/A
pnpm: 7.12.2
Relevant packages:
next: 13.1.5-canary.2
eslint-config-next: N/A
react: 18.2.0
react-dom: 18.2.0
Which area(s) of Next.js are affected? (leave empty if unsure)
Dynamic imports (next/dynamic)
Link to the code that reproduces this issue
https://github.com/sebpettersson/next-dynamic-bug
To Reproduce
Import a component with next/dynamic, build the project and then check the rendered markup.

https://next-dynamic-bug.vercel.app/
Describe the Bug
When using a component imported with next/dynamic, the markup will contain <template> instead of correct SSR content.
NOTE: If JavaScript is enabled it is easy to miss this bug since the <template> will be switched out for the correct content.
Additional findings
- This bug was introduced in 13.0.7.
- If a custom
Document is used the, markup is rendered correctly - provided it is a functional component that doesn't use getInitialProps. If it is a class that extends Document from next/document, or a functional component that uses getInitialProps, the bug is still triggered.
- In
dev mode, the bug is only triggered the first time the page is loaded. On subsequent page loads the correct markup is output.
Expected Behavior
That server side rendered content contains the correct markup when using components imported with next/dynamic.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
Dynamic imports (next/dynamic)
Link to the code that reproduces this issue
https://github.com/sebpettersson/next-dynamic-bug
To Reproduce
Import a component with
next/dynamic, build the project and then check the rendered markup.https://next-dynamic-bug.vercel.app/
Describe the Bug
When using a component imported with
next/dynamic, the markup will contain<template>instead of correct SSR content.NOTE: If JavaScript is enabled it is easy to miss this bug since the
<template>will be switched out for the correct content.Additional findings
Documentis used the, markup is rendered correctly - provided it is a functional component that doesn't usegetInitialProps. If it is aclassthat extendsDocumentfromnext/document, or a functional component that usesgetInitialProps, the bug is still triggered.devmode, the bug is only triggered the first time the page is loaded. On subsequent page loads the correct markup is output.Expected Behavior
That server side rendered content contains the correct markup when using components imported with
next/dynamic.Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response