AbsoluteJS

Static Generation

Pre-render pages at build time for instant load times. Optionally re-render stale pages in the background with ISR.

#Static Site Generation (SSG)

By default, AbsoluteJS renders every page on each request using streaming SSR. With the static config, pages are pre-rendered at build time and served as cached HTML: no SSR overhead per request.

Set routes: "all" to automatically crawl your site from / and pre-render every linked page:

TS
// absolute.config.ts
import { defineConfig } from "@absolutejs/absolute";

export default defineConfig({
  reactDirectory: "./src/frontend/react",
  svelteDirectory: "./src/frontend/svelte",
  // ...
  static: {
    routes: "all",
  },
});

When you run absolute start, the build step now includes pre-rendering:

BASH
$ absolute start

  Building assets (3.15s)
  Bundling production server (544ms)
  Pre-rendering static pages (5 pages, 512ms)

  ABSOLUTEJS v0.19.0  ready in 4.19s

  Local: http://localhost:3000/

Instant Loads

Pre-rendered HTML is served directly from disk : no SSR computation on each request.

Client Hydration

Pages still hydrate on the client: same interactive experience, just faster initial load.

SSR Fallback

Routes not in the static config still use SSR on demand: mix static and dynamic pages freely.

#Choosing Routes

Instead of pre-rendering everything, you can specify exactly which routes to pre-render:

TS
// absolute.config.ts
import { defineConfig } from "@absolutejs/absolute";

export default defineConfig({
  reactDirectory: "./src/frontend/react",
  // ...
  static: {
    routes: ["/", "/about", "/pricing", "/blog"],
  },
});

Routes not listed here will use SSR at request time as usual. This is useful when some pages have user-specific content that can't be pre-rendered.

With "all", AbsoluteJS starts from / and follows every internal <a href> link to discover pages automatically. Any page that's linked from another page will be found and pre-rendered.

#Incremental Static Regeneration (ISR)

SSG pages are rendered once at build time and stay static. With revalidate, pages automatically refresh in the background after a set interval:

TS
// absolute.config.ts
import { defineConfig } from "@absolutejs/absolute";

export default defineConfig({
  reactDirectory: "./src/frontend/react",
  // ...
  static: {
    routes: "all",
    revalidate: 60, // re-render stale pages every 60 seconds
  },
});
Without revalidatepure SSG: pages are rendered once at build time and never change
With revalidateISR: stale pages are served immediately while a fresh version renders in the background

#How ISR Works

TS
// How ISR works at runtime:

// 1. Page pre-rendered at build time (e.g. 12:00:00)
//    revalidate: 60 means it's valid for 60 seconds

// 2. Request at 12:00:30 → serves cached HTML instantly (still fresh)

// 3. Request at 12:01:15 → page is stale (75s > 60s)
//   : Serves the stale HTML immediately (no waiting)
//   : Triggers a background re-render
//   : Fresh HTML is saved to disk

// 4. Next request → gets the freshly re-rendered page

The user never waits for a re-render. Stale pages are served instantly: the fresh version is ready for the next visitor. This gives you the performance of static pages with the freshness of SSR.

#Type Reference

TS
type StaticConfig = {
  /** Routes to pre-render. Use "all" to crawl and discover all linked pages. */
  routes: string[] | "all";

  /** Revalidation interval in seconds (ISR). Optional. */
  revalidate?: number;
};