Replies: 2 comments 5 replies
-
@haishanh Can you clarify why you are using a Route Handler for this instead of just using a regular component? |
Beta Was this translation helpful? Give feedback.
-
I want to convert a component to an HTML string inside a route handler so that I can pass it to a PDF generator. This would seem like the cleanest and most logical way of doing but this limitation prevents this approach. I'm not sure why. I guess the hacky workaround would be to create a normal route to just produce the HTML I need, and then Advice welcome. Edit: a solution is detailed on this ticket. Be wary though as this could be a rabbit hole. Take a look at React's |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
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:
Beta Was this translation helpful? Give feedback.
All reactions