Krate Docs

#Rendering Modes

Choose between static (SSG), incremental (ISR), per-request (SSR), and streamed rendering.

Krate is SSG-first: every page is pre-rendered to static HTML at build time. On top of that base, pages can opt into ISR, SSR, or Streaming via a small per-page config or by using the components that imply them.

The architecture is static-first: the Go compiler bakes as much as possible into a static shell (layout, <head>, server components, resolved suspense content). Only genuinely dynamic pieces - the "regions" of a page - are rendered at request time by a small sidecar and spliced into the shell. Krate never re-renders an entire page just to update one dynamic part, and it never renders a page twice.

#Modes at a glance

Mode Config Output
SSG (default) - Fully static HTML, no request-time work
ISR export const config = { isr: true, revalidate: 60 } Static shell; page body cached per URL variant and revalidated in the background
SSR export const config = { ssr: true } Static shell; page body rendered fresh on every request
Streaming export const config = { streaming: true }, <Suspense>, or runtime components Static shell; each dynamic region streamed in as it resolves

Precedence when several apply: isr > ssr > streaming > ssg.

#SSG (default)

export default function Page() {
  return <h1>Hello, World!</h1>;
}

The page is rendered once at build time. The output is a static HTML file plus a hydration bundle. This is the fastest and most portable mode - it works on any static host.

Server components (// @server) are evaluated at build time and their output is baked into the static HTML, so build-time data needs no special page-level function. See Data Fetching.

Components without client state (no signals or handlers) are also rendered entirely at build time. Their expressions follow JavaScript and React semantics: {false}, {null} and {undefined} render nothing, {0 && <b/>} renders 0, strings are always escaped (only JSX is markup), and array methods such as filter, map, find and join run on build-time data. Every value such a component renders must be known at build time (a prop, a local, or a module constant); an expression that cannot be evaluated, or a component that cannot be resolved, fails the build with a diagnostic instead of rendering empty output. Browser globals like window are undefined there, exactly as under server rendering.

#ISR (Incremental Static Regeneration)

Opt a page in with the isr flag. revalidate (seconds) controls how often the page body is regenerated in the background:

export const config = { isr: true, revalidate: 60 };

export default function PricesPage() {
  return <p>Latest prices</p>;
}

The Next.js-style segment exports work too: export const revalidate = 60 is ISR, revalidate = 0 or export const dynamic = "force-dynamic" is SSR, and dynamic = "force-static" / revalidate = false keep the page static. A page that states no mode but reads tagged or timed data (fetch next options, unstable_cache) becomes ISR automatically. To purge ISR pages when data changes, call revalidatePath / revalidateTag; see Caching and Revalidation.

ISR responses are cacheable: Krate emits Cache-Control: public, s-maxage=..., stale-while-revalidate=... so CDNs hold fresh HTML while the sidecar revalidates stale entries in the background. revalidate defaults to 60 seconds when omitted.

For dynamic routes with generateStaticParams (Data Fetching), known variants are baked as static files at build time. Unknown variants render on demand through the page region and are cached per variant (URL params and query string are part of the cache key).

#SSR

export const config = { ssr: true };

The page shell is baked, and the page body is rendered by the sidecar on every request with the live URL params/query. Responses are no-store.

#Streaming

Streaming pages use Suspense boundaries and runtime components. The shell is baked with each dynamic boundary's fallback in place; as each region resolves it is streamed to the client and spliced in - one render per region, no two-phase full-page render.

// @runtime
export default function PriceTag({ price }) {
  return <span>{price}</span>;
}
export const config = { streaming: true };

Pages that render a runtime component or use <Suspense> are automatically treated as streaming even without the config:

export default function LivePage() {
  return (
    <Suspense fallback={<p>Loading...</p>}>
      <LiveStatus />
    </Suspense>
  );
}

#Choosing an approach

Need Approach
Static content, fastest SSG (default)
Data at build time Server component (@server)
Per-request data Runtime component (@runtime) + Streaming
Content that updates on a schedule ISR (isr + revalidate)
Fully per-request page SSR (ssr)
Static + dynamic route URLs generateStaticParams

See Component Tiers for how server and runtime components work, and Data Fetching for the full data model. For how the static shell and sidecar are wired, see Contributing -> Rendering internals.

Last updated: 2026-11-17

Contributors: Noinkin