Answer the question
In order to leave comments, you need to log in
How to use SSR via react-dom/server with CSS Modules?
I'm making SSR using React and CSS Modules.
You need to do this without third-party solutions (like Next.js), but with pure react-dom/server.
At the moment there is the following application:
import styles from "./MyModule.module.scss";
...
<div className={styles.colorRed}>Test</div>
...
<div>Test</div>
Answer the question
In order to leave comments, you need to log in
In general, I began to use Razzle . It is not practical to eject a configuration, or write an additional one for the sake of SSR.
You are doing something wrong:
import React from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import styles from './MyModule.module.css';
const html = renderToStaticMarkup(<div className={styles.colorRed}>Test</div>);
console.log(html); // <div class="src_MyModule_module__colorRed">Test</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question