Next.js Discord

Discord Forum

( Novice here ) Using react-dom/server but its throwing an error

Unanswered
Barbary Lion posted this in #help-forum
Open in Discord
Barbary LionOP
I was trying to download an html of an template for this i tried making an function by using renderToString
 import Template1 from "../template/template1/Template"; 
import useTemplateDataStore from "../store/templateDataStore"; 
import { renderToString } from "react-dom/server"; 
 
export default function generateHtml() { 
  const templateData = useTemplateDataStore.getState().templateData; 
  const html = renderToString(<Template1 data={templateData} />); 
 
  return html; 
}


But its throwing me an error that i cant use it in client component but generate template is not a client component im not using use client here

1 Reply

Kokoni
I believe react-dom/server is unsafe everywhere. It says nothing about it being a client component. You might try another way of doing html rendering.