Skip to main content

Overview

How a request is served

An app declares its locales, its preferences and its flags once, in lib/indicators.ts.

Outline
  • Sections:
    • What a request goes through
    • The three segments
    • What the app has to do
    • What runs, and what does not
    • What it does not do

Read more

Indicators

Metadata about a user is not enough to know what they want.

Outline
  • Sections:
    • Why these are only indicators
    • Preferences
    • Flags
    • Why keep them apart
    • What goes where
    • Headers a browser sends only when asked

Read more

Paths

Next derives a cache key from the request path.

Outline
  • Sections:
    • The most specific key
    • The encoding
    • Lumping
    • Why not Vary
    • A cache in front
    • Daylight saving time

Read more

Rewrites

withFairGardenIndicators adds a chain of rewrites to next.config.ts.

Outline
  • Sections:
    • The chain
    • What is left alone
    • Internal paths from outside
    • Redirects
    • Hard flags
    • Order

Read more

Static generation

Every segment is a dynamic route param, so prerendering a variant is ordinary generateStaticParams.

Outline
  • Sections:
    • Every variant, from one layout
    • One level at a time
    • The hot path and the long tail
    • A route that switches on a flag
    • Preferences that need no variant
    • What makes a page dynamic anyway

Read more

Hard flags

A hard flag gates a whole route tree.

Outline
  • Sections:
    • Why not a flag
    • Where the value lives
    • Pages without a version
    • What a visitor cannot do

Read more

Stylesheets

A site with many heavy pages cannot afford a copy of each per preference.

Outline
  • Sections:
    • How it is served
    • On some pages only
    • The round trip, and the preload
    • What the files say
    • Changing it
    • What it changes

Read more

Locales

A public URL means one locale.

Outline
  • Sections:
    • Detection, at the root only
    • A chosen locale
    • The default locale's prefix
    • Links

Read more

Layouts

The three segments are three directories, and any of them can have a layout.

Outline
  • Sections:
    • Where the root layout goes
    • Reading without the wrapper
    • Not found
    • Client components

Read more

In a monolith

@fairgarden/monolith mounts several apps into one deployment, each under a prefix, and merges their rewrites, redirects and headers with that prefix applied.

Outline
  • Sections:
    • The config merges
    • Links carry the mount
    • The proxy moves
    • Cookies are shared

Read more