Dinou is Static by Default. At the route level, it provides a clean continuum from build-time SSG, stale-while-revalidate ISR, and on-demand ISG to real-time Dynamic SSR.
In Dinou, every route is assumed to be static until proven otherwise. During dinou build, the compiler analyzes your route segments, components, and loader functions to evaluate whether a route can be pre-rendered or if it requires real-time request data:
revalidate >= 1 (ISR) or generate long-tail dynamic paths on their first visit (ISG).revalidate = 0, Dinou automatically transitions the route to Live SSR on every request.Need to combine static shells, cached subtrees, and independent layout TTLs on the same route? Explore Dinou's 3D Layered Segmentation (PPR, <DinouCacheSlot>, and layout_functions.ts).
Pure static rendering pre-generates HTML and RSC Flight files during the build phase (dinou build). Production server startup is instantaneous, and static pages achieve the fastest possible Time to First Byte (TTFB) directly from Dinou's built-in cache.
Any page that does not consume request-specific headers, cookies, or query parameters (context.req.query) and does not set revalidate < 1 is automatically generated as static HTML:
// src/about/page.tsx
// Automatically rendered as static HTML during build time
export default function AboutPage() {
return (
<article className="prose">
<h1>About Us</h1>
<p>This page is pre-rendered once and served statically forever.</p>
</article>
);
}In standard route-level rendering (without Partial Prerendering), if a Server Component reads request-specific data at render time, Dinou automatically “bails out” of static generation and transitions the entire page into Dynamic SSR for that request:
// src/profile/page.tsx
import { getContext } from "dinou";
import db from "@/lib/db";
export default async function ProfilePage() {
const context = getContext();
// ⚠️ Reading cookies triggers an Automatic Static Bailout
// This page will now be rendered dynamically on every incoming request
const sessionToken = context.req.cookies["session_token"];
const user = await db.users.findByToken(sessionToken);
return <h1>Welcome back, {user?.name}</h1>;
}context.req.cookies, context.req.headers, or context.req.query, calling useSearchParams() inside a Server Component, or mutating the response (context.res.cookie(), clearCookie(), setHeader(), status(), redirect()) during Server Component or getProps execution. Calling getContext() alone (or reading context.req.path, context.req.method, or context.env) preserves static rendering. (To isolate a bailout to a single <Suspense> hole without de-optimizing the rest of the page, see Partial Prerendering (PPR)).useSearchParams()?Client Components ("use client") that call useSearchParams() never trigger dynamic bailout. The route remains 100% eligible for static pre-rendering (SSG), on-demand ISG caching, background ISR regeneration, static PPR shells, and pure static exports (export-static).
✅Zero-Boilerplate Hydration Safety
Dinou's useSearchParams() hook automatically prevents React hydration mismatches on cached static and PPR pages. During static HTML generation and the browser's initial hydration pass, it deterministically returns an empty URLSearchParams instance (matching the cached HTML), and immediately re-renders on the client with the live URL query string—no manual useState or useEffect wrapper needed:
// src/components/search-filter.tsx
"use client";
import { useSearchParams } from "dinou";
export function SearchFilter() {
const searchParams = useSearchParams();
const query = searchParams.get("q") ?? "";
if (!query) {
return <span className="text-muted-foreground">Showing all items</span>;
}
return (
<span>
Filter: <strong>{query}</strong>
</span>
);
}useSearchParams() (or read context.req.query) inside a Server Component—either on a full Live SSR route (export const revalidate: PageFunctions["revalidate"] = 0;) or wrapped in <Suspense> with export const ppr = true;.revalidate Strategy (Seconds)In Dinou, the revalidate export in page_functions.ts (or layout_functions.ts) serves as the single source of truth for the route segment's rendering mode. It is measured strictly in seconds (s).
revalidate < 1 or 0)To force a page to render dynamically on every single request (escaping the default static generation), set revalidate to 0 (or any number < 1):
// src/analytics/live/page_functions.ts
import type { PageFunctions } from "./dinou";
// Escapes static generation: executes dynamic SSR on every request
export const revalidate: PageFunctions["revalidate"] = 0;export function dynamic(). In Dinou, the dynamic export has been removed. Setting export const revalidate = 0; is the official unified mechanism to escape static generation.revalidate >= 1)When revalidate >= 1, Dinou serves pre-rendered static HTML/RSC payloads while regenerating the page in the background at most once every N seconds (stale-while-revalidate):
// src/blog/page_functions.ts
import type { PageFunctions } from "./dinou";
// Rebuilds the cached page in the background at most once every 60 seconds
export const revalidate: PageFunctions["revalidate"] = 60;
// Or as a sync/async function:
// export const revalidate: PageFunctions["revalidate"] = () => 60;60 for 1 minute, 3600 for 1 hour). If false or omitted, the page remains cached until purged on demand via revalidatePage, revalidateLayout, revalidatePath, or revalidateTag.While ISR updates existing pre-rendered pages, ISG (Incremental Static Generation) generates new pages on demand that were not included in the initial build-time getStaticPaths list.
Any route path omitted from getStaticPaths will be generated dynamically when the first visitor requests it, cached, and then served as static HTML to subsequent visitors:
// src/products/[id]/page_functions.ts
import type { PageFunctions } from "./dinou";
// Pre-render only the top 10 products at build time
export const getStaticPaths: PageFunctions["getStaticPaths"] = [
"1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
];
// Any other ID (e.g. /products/452) will be generated on-demand
// on its first visitor and cached permanently.validateParams & allowISG)Dinou provides strict server-side governance exports in page_functions.ts and layout_functions.ts to secure dynamic generation against abuse (see Page & Layout Functions for full details):
Validates dynamic parameters before generation. Returning false halts rendering and returns 404 immediately.
import type { PageFunctions } from "./dinou";
export const validateParams: PageFunctions["validateParams"] = (params) => {
return typeof params?.id === "string" && /^\d+$/.test(params.id);
};Controls on-demand generation (accepts a boolean or sync/async function, and can also be defaulted globally in dinou.config.ts). When false, any path omitted from getStaticPaths returns 404 instantly.
import type { PageFunctions } from "./dinou";
export const allowISG: PageFunctions["allowISG"] = false; // Strict SSG onlySummary of the route-level rendering strategies supported natively by Dinou:
| Strategy | How to Configure | TTFB | Freshness | Database Load | Best For |
|---|---|---|---|---|---|
| Pure SSG | Default / revalidate = false | ~1.45ms (Cached) | Build-time | 0 queries (Build-time only) | Landing pages, marketing, documentation |
| ISR | revalidate = N (N >= 1) | ~1.18ms (Cached SWR) | Stale-while-revalidate | 1 query per TTL (0 on cache hits) | Blogs, catalogs, news feeds |
| ISG (Incremental Static) | allowISG = true (default) | Cached (after 1st hit) | Cached permanently (or per ISR TTL) | 1 query on 1st generation (0 thereafter) | Long-tail e-commerce products, dynamic paths |
| Dynamic SSR | revalidate = 0 (or request data access) | Request-time (Streams via <Suspense>) | 100% Real-time | Heavy: 100% queries on every request | User settings, banking, checkout |