Read the docs | See the live examples
microsite
is a fast, opinionated static-site generator (SSG) built on top of Snowpack. It outputs extremely minimal clientside code using automatic partial hydration.
npm init microsite <project>
Microsite is an ESM node package, so it needs to run in a Node environment which supports ESM. We support the latest version of
node
v12.x LTS (Erbium) โ see Engines for more details.Ensure that your project includes
"type": "module"
inpackage.json
, which will allow you to use ESM in your project'snode
scripts.
Pages
Microsite uses the file-system to generate your static site, meaning each component in src/pages
outputs a corresponding HTML file.
Page templates are .js
, .jsx
, or .tsx
files which export a default
a Preact component.
Styles
Styles are written using CSS Modules. src/global.css
is, as you guessed, a global CSS file injected on every page.
Per-page/per-component styles are also inject on the correct pages. They are modules and must be named *.module.css
.
Project structure
project/
โโโ public/ // copied to dist/
โโโ src/
โ โโโ global/
โ โ โโโ index.css // included in every generated page
โ โ โโโ index.ts // shipped entirely to client, if present
โ โโโ pages/ // fs-based routing like Next.js
โ โ โโโ index.tsx
โโโ tsconfig.json
Acknowledgments
-
Markus Oberlehner,
vue-lazy-hydration
- Markus Oberlehner, Building Partially Hydrated, Progressively Enhanced Static Websites with Isomorphic Preact and Eleventy
- Lukas Bombach, The case of partial hydration (with Next and Preact)
- Jason Miller and Addy Osmani, Rendering on the Web
-
Poimandres,
valtio
for inspiringmicrosite/global