IssueRaiser

Unable to import react-dom/server in a server component

### Verify canary release - [X] 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.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 throug

Posted by janus-reith on Dec 7, 2022, 12:22 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.2,500 issues0 comments

github (SaaS)

Unable to import react-dom/server in a server component

janus-reithDec 7, 2022, 12:22 PM

### Verify canary release - [X] 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.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 throug

Comments (0)

No comments yet. Start the discussion.

Comment on this issue