Verify canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 22.1.0: Sun Oct 9 20:14:30 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T8103
Binaries:
Node: 16.18.0
npm: 8.19.2
Yarn: 1.22.19
pnpm: 7.13.6
Relevant packages:
next: 13.0.7-canary.1
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)
App directory (appDir: true)
Link to the code that reproduces this issue
https://stackblitz.com/edit/vercel-next-js-arwqsz?file=app%2Fpage.js
To Reproduce
app/page.js:
import ReactDOMServer from "react-dom/server";
const staticMarkup = ReactDOMServer.renderToStaticMarkup(<p>TEST</p>);
export default function TestPage() {
return <p>123</p>;
}
Run next dev and try opening the index page.
Describe the Bug
I'm receiving an error message:
Failed to compile.
./app/page.js
You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security.
Maybe one of these should be marked as a client entry "use client":
app/page.js
Expected Behavior
Be able to use react-dom/server on the server.
My usecase it to take some React tree, render it so markup, run it through another postprocessing step which is not aware of anything React specific, and then, return an iframe containing that html.
Contrary to what the error message says, I think there's nothing to fix about importing react-dom/server, and neither should any of this require using the "use client" directive
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
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 22.1.0: Sun Oct 9 20:14:30 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T8103
Binaries:
Node: 16.18.0
npm: 8.19.2
Yarn: 1.22.19
pnpm: 7.13.6
Relevant packages:
next: 13.0.7-canary.1
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)
App directory (appDir: true)
Link to the code that reproduces this issue
https://stackblitz.com/edit/vercel-next-js-arwqsz?file=app%2Fpage.js
To Reproduce
app/page.js:Run
next devand try opening the index page.Describe the Bug
I'm receiving an error message:
Failed to compile.
./app/page.js
You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security.
Maybe one of these should be marked as a client entry "use client":
app/page.js
Expected Behavior
Be able to use
react-dom/serveron the server.My usecase it to take some React tree, render it so markup, run it through another postprocessing step which is not aware of anything React specific, and then, return an iframe containing that html.
Contrary to what the error message says, I think there's nothing to fix about importing react-dom/server, and neither should any of this require using the "use client" directive
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response