react
react copied to clipboard
generateHydrationScript for React?
In SolidJS for SSR you can use something called generateHydrationScript
:
import { generateHydrationScript } from "solid-js/web";
const app = renderToString(() => <App />);
const html = `
<html lang="en">
<head>
<title>🔥 Solid SSR 🔥</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="/styles.css" />
${generateHydrationScript()}
</head>
<body>${app}</body>
</html>
`;
What this does is it will automatically inject the necessary hydration script into the page so you don't have to worry about hydrating stuff in client-side scripts.
Is there anything out there like this for React?