💧SSR / SSG
Implement SSR and SST without friction
Node
Atomico and automatic SSR support, you will not need additional packages, example:
// If your version of node accepts top-level await just point to 'atomico/ssr'
import 'atomico/ssr/load';
import { html } from 'atomico';
import { Component } from './static/component.js';
import express from 'express';
const app = express();
const port = 3010;
app.use(express.static('static'));
app.get('/', (req, res) => {
res.send(`
<script type="importmap">
{
"imports": {
"atomico": "https://unpkg.com/atomico"
}
}
</script>
<script src="./component.js" type="module"></script>
${html`<${Component} value=${100}>
<h1>Message from server!</h1>
</${Component}>`.render()}
`);
});
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
});
For this case we are using a JS-only component to avoid compilation in the example. you can achieve the same with JSX or TSX.
You will not need any additional package, atomic internally understands that the component must be hydrated
Unlike other libraries, Atomico automatically hydrates when mounting the component in the DOM, so no additional client configuration is required.
SSR/SSG via @atomico/react
The @atomico/react package allows you to take advantage of support for SSR or SSG designed for React/Preact, example:
Next.js:
Astro build
@atomico/astro allows to integrate SSR and SSG support to Astro build, We have used this integration to create the atomicojs.dev site.
Last updated
Was this helpful?
