A minimal and flexible Node.js + React SSR utility for rendering React components from a Node.js/Express backend with built-in TypeScript support.
- ⚛️ Simple React component rendering on the server
- 🧩 Supports TypeScript out of the box
- 🔒 Escapes HTML to prevent injection
Using npm:
npm install @scaflo/node-react-wrapper
Using pnpm:
pnpm add @scaflo/node-react-wrapper
Using yarn:
yarn add @scaflo/node-react-wrapper
import express from "express";
import { renderSSR } from "@scaflo/node-react-wrapper";
import App from "./App"; // Your React component
const app = express();
app.get("/", (_req, res) => {
const html = renderSSR({
App,
title: "this trial SSR is working",
cssPath: "/styles/index.css", // if using Tailwind, else import CSS directly in JSX
jsPath: "/client.js",
});
res.send(html);
});
app.listen(3000, () => console.log("Server is running on http://localhost:3000"));
import React from "react";
interface AppProps {
message: string;
}
const App: React.FC<AppProps> = ({ message }) => {
return <div>{message}</div>;
};
export default App;
Check out the full working example here: 👉 https://github.com/scaflo/express-react-ssr-trial
ISC © Scaflo