HeliumTS is under active development and may have bugs or breaking changes. Report issues on GitHub.

Static Site Generation (SSG)

HeliumTS supports Static Site Generation by pre-rendering pages at build time. It is the right fit for pages that should ship real HTML but do not need request-time data.

Add a "use ssg"; directive at the top of your page component to enable SSG:

src/pages/about.tsx

1"use ssg";
2
3import React from "react";
4
5export default function AboutPage() {
6 return (
7 <div>
8 <h1>About Us</h1>
9 <p>This page is statically generated at build time.</p>
10 </div>
11 );
12}

During build, Helium validates SSG pages, renders them ahead of time, and writes static HTML into the build output.

When to Use SSG

  • Documentation, marketing pages, and other mostly static content.
  • Pages where SEO matters but the content changes infrequently.
  • Hybrid pages where the shell is static and dynamic data loads after hydration.

How It Works

  1. Helium scans src/pages for files containing "use ssg";.
  2. Each page is checked for SSG compatibility.
  3. The page is rendered at build time and written to the final output as HTML.

Layouts, App Shells, and Output

SSG uses the same optional app shell, nested layouts, and page-transition wrappers as client rendering. Static pages receive params: {} and an empty URLSearchParams as searchParams. Use SSR for request-dependent HTML.

1dist/
2├── index.ssg.html # pre-rendered home page, served for /
3├── index.html # empty SPA fallback for other routes
4└── about.html # pre-rendered /about page

Dynamic routes are skipped because build-time parameter generation is not supported. Sidecars, declaration files, layouts, and the _app shell are excluded from page discovery.

SSG vs SSR

Use SSG when the HTML can be generated once at build time. Use "use ssr"; when the markup depends on per-request data such as authenticated users, headers, or database lookups.