You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I expect no error on importing "react-dom/server" in route.ts. In my route.ts GET method, I'd like to render html string templated using React. It maybe not a very common use case, given we are using Next.js, but should be a legit one.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.1.0: Thu Nov 14 18:19:02 PST 2024; root:xnu-11215.41.3~13/RELEASE_ARM64_T8132
Available memory (MB): 24576
Available CPU cores: 10
Binaries:
Node: 20.18.0
npm: 10.8.2
Yarn: N/A
pnpm: 10.4.0
Relevant Packages:
next: 15.1.7 // Latest available version is detected (15.1.7).
eslint-config-next: 15.1.7
react: 19.0.0
react-dom: 19.0.0
typescript: 5.7.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Module Resolution
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local)
Additional context
What shows in my terminal:
⨯ ./src/app/foo/render.ts:2:1
Ecmascript file had an error
1 | import * as React from "react";
> 2 | import * as ReactDomServer from "react-dom/server";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 |
4 | export function render() {
5 | return ReactDomServer.renderToStaticMarkup(
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.
Learn more: https://nextjs.org/docs/app/building-your-application/rendering
And in the browser:
The text was updated successfully, but these errors were encountered:
Link to the code that reproduces this issue
https://github.com/haishanh/nextjs-react-dom-render-reprod
To Reproduce
Current vs. Expected behavior
I expect no error on importing "react-dom/server" in route.ts. In my route.ts
GET
method, I'd like to render html string templated using React. It maybe not a very common use case, given we are using Next.js, but should be a legit one.Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 24.1.0: Thu Nov 14 18:19:02 PST 2024; root:xnu-11215.41.3~13/RELEASE_ARM64_T8132 Available memory (MB): 24576 Available CPU cores: 10 Binaries: Node: 20.18.0 npm: 10.8.2 Yarn: N/A pnpm: 10.4.0 Relevant Packages: next: 15.1.7 // Latest available version is detected (15.1.7). eslint-config-next: 15.1.7 react: 19.0.0 react-dom: 19.0.0 typescript: 5.7.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Module Resolution
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local)
Additional context
What shows in my terminal:
And in the browser:
The text was updated successfully, but these errors were encountered: