Skip to content

Reading the session cookie in the root layout made the whole site dynamic #22

Description

@nastyaeremina

Shipped in 2026-08-24.7 knowingly, tracked here.

What happened

#21 fixed the auth-aware nav by reading current-portal-session with cookies() in src/app/layout.tsx. It is the correct read (the cookie is HttpOnly), but it happens in the root layout, which wraps every route. Reading a cookie there opts the entire site out of static rendering.

The measurement

npm run build, previous release vs. current main:

2026-08-24.6 main (post-#21)
Static / ISR routes ~40, plus 785 prerendered pages sitemaps + /llm-info only
/, /pricing, /blog, /customers, /jobs, /legal/* static ƒ server-rendered on demand

Confirmed live: https://assembly.com/ now answers cache-control: private, no-cache, no-store with x-vercel-cache: MISS.

Why it matters

  • Pages no longer come off the CDN, so TTFB rises for every visitor, crawlers included.
  • The revalidate windows on / (5m), /about (1h), /templates (5m) and friends are inert. Ghost and Contentful are now fetched per request.
  • Vercel function invocations go up across the whole site rather than for the nav alone.

Nothing is broken and nothing looks different. It is slower and it costs more.

The fix

Move the cookie read somewhere narrower than the root layout so only the auth-dependent surface is uncached:

  • Middleware stamping a header or a readable cookie that the layout reads, keeping the pages themselves static. Note that a value baked into a static page cannot vary per visitor, so the variant still has to be chosen at the edge or on the client.
  • Or a small dynamic component holding the cookies() call, wrapped in <Suspense>, so Next's partial prerendering keeps the rest of the page static.

Whichever way, the acceptance check is the build table: /, /pricing, /blog and the [slug] families back to , with the signed-in nav still correct on the live host.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions