Skip to content

fix(cow-fi): server-render pages by isolating UTM useSearchParams - #8548

Draft
riboflavin wants to merge 1 commit into
cowprotocol:developfrom
riboflavin:fix/cow-fi-ssr-utm-suspense
Draft

riboflavin wants to merge 1 commit into
cowprotocol:developfrom
riboflavin:fix/cow-fi-ssr-utm-suspense

Conversation

@riboflavin

Copy link
Copy Markdown
Contributor

Summary

Makes cow-fi pages server-render their content in production. Today most pages ship an almost empty HTML shell and fill in on the client, so crawlers (including AI/LLM crawlers that don't run JS) see little or nothing.

  • Layout ('use client') called useSetupPage() → useInitializeUtm() → useSearchParams(). Under the app-wide <Suspense> in app/providers.tsx, that makes Next bail out of prerendering the whole page to client-side rendering.
  • Moves the useSetupPage() call into a new UtmInitializer client component that renders null, wrapped in its own <Suspense fallback={null}> inside Layout. Only that empty boundary is client-rendered now.
  • Removes the outer <Suspense> from app/providers.tsx. Leaving it in made page content stream inside a hidden <div hidden id="S:0"> instead of inline in the HTML.

No changes to routing, caching (revalidate), data fetching, or UTM logic.

To Test

Needs a production build; dev mode doesn't reproduce this (next build && next start in apps/cow-fi).

  1. curl -s http://localhost:3000/resources/price-guide (or view source)
  • The page's titles and descriptions are in the HTML, not just an empty shell
  1. Same for an article, / and /cow-swap
  • Article body, home and product page text are present in the HTML
  1. UTM
  • Open /?utm_source=test&utm_medium=qa&utm_campaign=x: params are stripped from the URL after a few seconds, and home page links still carry utm__source=cow.fi&utm__medium=web&utm__content=...
  1. Missing campaign
  • /resources/campaign and /resources/price-guide/nope return HTTP 404

Background

Visible words in the prerendered HTML (production build), before → after:

Page Before After
Article (USDT price guide) 10 1,979
/resources/price-guide 2 542
/resources 1 87
/ 21 242
/cow-swap 7 516

The only remaining bailout marker is the empty UtmInitializer boundary. As a side effect, missing campaigns/resources now return a real 404 instead of a 200 soft 404.

UTM behavior was compared in a browser against an unchanged baseline build: URL cleanup and link params are identical.

Not addressed: unknown top-level URLs (e.g. /this-page-does-not-exist) still return 200 via the catch-all route; that is pre-existing.

Local checks: cow-fi:test (106 tests), lint (0 errors), agents:check, and cow-fi:test-cms-resilience (CMS unavailable / malformed / stalled, 46 pages each) pass. I'm relying on CI for typecheck.

Self-checks

  • I have read CONTRIBUTING.md
  • I have manually tested changes on Vercel preview deployment
  • I have done self-review and (or) AI review
  • I have addressed all comments from @coderabbitai
  • I have less than three open PRs/Stacks in this repo at the moment of creating this PR

@coderabbitai

coderabbitai Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@vercel

vercel Bot commented Nov 8, 2026

Copy link
Copy Markdown

@riboflavin is attempting to deploy a commit to the cow-dev Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Nov 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
rwa-dev Skipped Skipped Nov 8, 2026 8:14pm UTC

Request Review

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant