Cookie banner is part of the first render: in the server HTML, decided before the first paint; pages stay static

Until now CookieBanner rendered nothing until the page had hydrated and an effect had read the cookie, so on a first
visit it appeared late and became the LCP element on text pages (request from a client project, 2026-11-26).

- The banner is rendered on the server with `hidden`, followed by one inline script (consentBannerScript) that,
  before the browser paints, shows it (no current decision) or keeps it hidden (current decision). It decides as
  readConsentRecord does. A click on a banner button before hydration is kept and carried out once the page is live.
- The decision is read through a store (useSyncExternalStore): no hydration mismatch, the browser's value before
  the next paint. One decision per document.
- Optional server read (ConsentProvider cookieValue, SiteProviders consentCookie): exact HTML, dynamic pages.
- CookieBanner firstPaint={false} keeps the old behaviour; nonce from SiteProviders / ConsentProvider / the prop.
- Nothing about consent changes: no tag earlier, Consent Mode default first, cookie, consent log, withdrawal.

Tests: test/consentFirstPaint.test.ts (server render, script against readConsentRecord, hydration with no warning,
decisions, tags), reference e2e (static HTML, painted before hydration, returning visitor, early click).
Docs: consent.md "First paint", frontend.md, security.md, AGENT.md, skills, changelog draft under 1.17.0.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-26 12:08:59 +01:00
co-authored by Claude Fable 5.2
parent 2f6a81acbf
commit 177620da57
28 changed files with 983 additions and 76 deletions
+1
View File
@@ -683,6 +683,7 @@ Do one item at a time, build, check. Order by importance:
| 73 | **1.17.0 — e-mail: the Intecion mail service is the default transport** — a site with no SMTP server in the panel and no `GRAPH_*` starts sending through the service after the upgrade (an outbound call with its host; a new public route `POST /api/iapl/mail-relay/confirm`; mail from `[email protected]`); a Graph site warns at start | Nothing to run (no schema, migration or import-map change). SMTP site: nothing. Graph site: nothing now — deprecated, move when the owner says. Site with neither: agree it with the owner; `serverURL` = the public address, "Sender address" filled in, the host listed by Intecion; or `iapl({ mail: { relay: false } })` to keep the old behaviour | `iapl-upgrade` "→ 1.17.0, e-mail", AGENT.md §7.2, email.md |
| 74 | **1.17.0 — Postgres** — a Postgres site with many form submissions or "forgot password" requests at the same moment stopped answering (every page waited); after the update `transactionWatchState` shows a reserve, form and account mail arrive a moment after the save | Nothing to run. Default: a fifth of the pool (at least 2) kept free of transactions; form, "forgot password" and "verify" mail sent right after the commit; shorter SMTP time-outs. The old way: `connectionReserve: false`, `forms: { emailsInTransaction: true }`, `mail: { accountMailAfterCommit: false }`. An own e-mail adapter calls `sendAccountMailAfterCommit` first. MongoDB / SQLite: no change | CHANGELOG 1.17.0 "Fixed — Postgres", deployment.md §4.3a, forms.md "When e-mails go out" |
| 75 | **1.17.0 — e-mail: launch day and copies** — a site moves from `<name>.dev.netscale.pl` to its real domain (the real domain must send with no click); or production's database is copied to a development or staging address (it must not mail real people); or the start stops with "`developmentHosts` must be an array of host patterns" | Nothing to run on launch day. A development address matching `iapl({ developmentHosts })` (built in `*.dev.netscale.pl`) or a site with `IAPL_NOINDEX=1` that holds another host's connection sends nothing until an admin presses "Connect again". Other staging hosts: add their pattern to `developmentHosts` (an array of non-empty patterns; `[]` = none). Production never keeps `IAPL_NOINDEX` | `iapl-upgrade` "→ 1.17.0, e-mail", email.md "Staging, copies and several hosts" |
| 76 | **1.17.0 — cookie banner at first paint** — the banner appeared seconds after the page (after hydration) and was the LCP element on text pages; or after the update an e2e test finds a hidden `[data-ipal="banner"]` for a returning visitor; or with a nonce CSP the console reports a refused inline script | Nothing to run: the banner is now in the server HTML and an inline script shows or hides it before the first paint; pages stay static; consent, tags and the log are unchanged. Remove a project "mounted" wrapper around the banner. Nonce CSP: `<SiteProviders nonce>`. Tailwind 3 with a `classNames.root` that sets `display`: `[data-ipal="banner"][hidden] { display: none !important }`. Old behaviour: `<CookieBanner firstPaint={false} />`; exact HTML on a dynamic site: `consentCookie` | `iapl-upgrade` "→ 1.17.0, cookie banner at first paint", consent.md "First paint" |
After updating the package: `pnpm exec iapl-skills` (new skill versions), `pnpm payload generate:importmap`, `rm -rf .next`, restart dev, grep for the new symbol in
`node_modules/@intecion/ipal-kit/dist`.