On this page
· 2 min read
Installation
This guide walks through setting up a static site that uses React for rendering and @pagesmith/site as the app-facing Pagesmith package. The example produces a fully static site — no client-side React runtime ships to the browser.
Dependencies
The project requires three groups of packages:
Pagesmith package — @pagesmith/site provides the app-facing collection APIs, Vite plugins, and shared runtime/CSS layer used by this example:
{ "dependencies": { "@pagesmith/site": "*", "react": "^19.2.4", "react-dom": "^19.2.4", "pagefind": "^1.5.0" }}React — react and react-dom are used exclusively at build time. renderToStaticMarkup converts JSX components into HTML strings during static generation.
Pagefind — listed as a dependency so the SSG plugin can index generated pages and produce a search index automatically.
Quick start
Clone the repository and install from the workspace root:
git clone https://github.com/sujeet-pro/pagesmith.gitcd pagesmithvp installRun the development server for this example:
vp run dev:eg:reactOr build for production:
cd examples/frameworks/with-reactvp buildThe production build writes to gh-pages/examples/react/ (configured via build.outDir in the Vite config).
What the Vite plugins provide
pagesmithContent— Markdown pipeline, Zod validation, andvirtual:content/<collection>modules consumed bysrc/entry-server.tsx.pagesmithSsg— Imports the entry, callsgetRoutes()/render(), writes HTML, runs Pagefind on the output, and setssearchEnabledinSsgRenderConfigwhen appropriate.sharedAssetsPlugin— Copies shared site assets (fonts, etc.) into the build.
Everything else is normal Vite (client entry, CSS, TypeScript).
Build-time React vs browser bundle
- Build — React +
renderToStaticMarkupturn JSX into HTML strings.renderDocumentShellwraps them in a full document (meta, styles, optional Pagefind shell,client.jsscript). - Browser —
client.jsloadstheme.css,@pagesmith/site/runtime/content(markdown/code presentation aligned with the server HTML), thensrc/runtime.tsfor TOC, sidebar, and theme UI. There is no React hydration step.
See Layouts & rendering and Search integration for data-pagefind-body placement and Pagefind behavior.