mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 15:39:13 +00:00
About 95% of the 404s served on supabase.com are App Router RSC prefetches (`?_rsc=`) that www `<Link>`s fire at paths another zone serves: `/docs`, `/dashboard`, `/library`, and the footer's `humans.txt`, `lawyers.txt` and `security.txt`. Next.js can't prefetch or client-navigate across multi-zone boundaries, so each prefetch 404s even though the link itself works. I turned every www link into another zone into a plain `<a>` and added a lint rule so new ones stay that way. **Changed:** - **Cross-zone links are plain anchors**: links that always leave www (literal `/docs`, `/dashboard` and `.txt` hrefs, absolute `https://supabase.com/dashboard` URLs, the `getDashboardCtaHref` CTAs) render `<a>`. Renderers whose href comes from data (nav, footer, plan and add-on CTAs, product cards) branch on `isCrossZoneHref`, which reads the zone list from `lib/rewrites.js`. In-zone links stay `<Link>` and keep prefetching. - **New literal links can't regress**: `www/no-cross-zone-link` errors on a `next/link` `<Link>` whose literal or template href points at another zone. It evaluates `lib/rewrites.js` as production, so `/docs` counts in every environment. - **Click tracking survives the full navigation**: `sign_in_button_clicked`, `start_project_button_clicked` and `www_pricing_plan_cta_clicked` now send with `keepalive`, like `sign_in_submitted` already did, so an immediate page load can't cancel them. The mobile nav Sign in and Start your project buttons used `legacyBehavior`, which never called their `onClick`: PostHog has no `Mobile Nav` location for either event in the last 30 days. Those clicks report from this PR on. - **Typecheck no longer crashes**: the functions page's default export inferred a type through `RealtimeLogs`'s unexported `Props`, which makes the native TypeScript compiler panic during `tsc --noEmit`. I exported `Props`. **Note:** the lint rule only sees literal hrefs. A new renderer whose href comes from data needs its own `isCrossZoneHref` branch, and review is the only check on that. ## To test `/docs` is only rewritten on production and absolute `https://supabase.com/...` links are cross-origin on a preview, so the preview proves the relative non-docs cases (`/dashboard*`, `/library`, the footer .txt files). `/docs/...` prefetches still appear on the preview because it has no docs rewrite. Tested on Vercel preview: - [x] Open `/` with the network tab filtered to `_rsc` and scroll to the footer: no requests for `/dashboard*`, `/library`, `/design-system`, `/kb`, `/evals`, `/humans.txt`, `/lawyers.txt` or `/.well-known/security.txt`, while in-zone ones such as `/pricing`, `/features` and `/blog` still appear - [x] Same check on `/pricing`, `/auth`, `/database`, `/storage`, `/realtime`, `/edge-functions`, `/blog` and a blog post: no `_rsc` requests to `/dashboard*`, `/library` or the footer .txt files - [x] Open the Developers dropdown on desktop and the mobile menu at 390px: no new `_rsc` requests to `/dashboard*` or `/library` - [x] Click header Docs, footer Humans.txt, the hero Start your project button and the pricing Free plan button: each lands where it did before (`/docs`, `/humans.txt` text, `https://supabase.com/dashboard/sign-up`, `https://supabase.com/dashboard/new?plan=free`). Signed out, the Free plan button lands on the dashboard sign-in with `plan=free&returnTo=%2Fnew` - [x] Click the hero Start your project button: the `/platform/telemetry/event` POST with `start_project_button_clicked` completes with a 2xx after the page starts navigating. 201 with the navigation held; on the real navigation the event still reached staging PostHog - [x] At 390px, open the mobile menu and click Sign in: a `/platform/telemetry/event` POST with `sign_in_button_clicked` and `buttonLocation: "Mobile Nav"` fires. Start your project in the same menu also sends `start_project_button_clicked` with `buttonLocation: "Mobile Nav"` - [ ] Signed in, load `/`: no `/dashboard/projects?_rsc=` request (not run: the preview origin has no signed-in session) - [x] Open the desktop Product dropdown and the Product section of the 390px mobile menu: Compute shows its Private Alpha badge and the other products show none (checks the master merge into `MenuItem`) After deploy, `/` and `/pricing` on supabase.com show no `_rsc` requests to `/docs*`, `/dashboard*` or `/library`. After a full day, the share of supabase.com 404s carrying `_rsc=` should drop from about 95% to under 10%, and `sign_in_button_clicked` and `start_project_button_clicked` should start showing a `Mobile Nav` location in PostHog. ## Linear - fixes GROWTH-1294
121 lines
3.9 KiB
TypeScript
121 lines
3.9 KiB
TypeScript
'use client'
|
|
|
|
import type { CTA } from '~/types/common'
|
|
import { useIsLoggedIn } from 'common'
|
|
import Link from 'next/link'
|
|
import React, { Children, type ReactNode } from 'react'
|
|
import { Button, cn } from 'ui'
|
|
|
|
import SectionContainerWithCn from '../Layouts/SectionContainerWithCn'
|
|
import ProductIcon from '../ProductIcon'
|
|
import { isCrossZoneHref } from '@/lib/cross-zone'
|
|
import { resolveDashboardCtaHref } from '@/lib/dashboard-links'
|
|
|
|
// to do: move types to be global
|
|
// then solutions.types.ts should extend this
|
|
interface Props {
|
|
label?: ReactNode
|
|
h1: ReactNode
|
|
subheader?: ReactNode
|
|
icon?: string
|
|
title?: string
|
|
image?: React.ReactNode
|
|
footer?: React.ReactNode
|
|
footerPosition?: 'left' | 'bottom' | 'right'
|
|
ctas?: CTA[]
|
|
className?: string
|
|
sectionContainerClassName?: string
|
|
}
|
|
|
|
const ProductHeader = ({ footerPosition = 'left', ...props }: Props) => {
|
|
const isLoggedIn = useIsLoggedIn()
|
|
|
|
return (
|
|
<div
|
|
className={cn(
|
|
'w-full max-w-full relative mx-auto py-16 lg:py-24 border-b bg-alternative overflow-hidden',
|
|
props.className
|
|
)}
|
|
>
|
|
<SectionContainerWithCn
|
|
height="none"
|
|
className={cn('grid grid-cols-12', props.sectionContainerClassName)}
|
|
>
|
|
<div
|
|
className={cn(
|
|
'relative z-10 col-span-12 lg:col-span-5',
|
|
// if not image is present, center the content
|
|
!props.image &&
|
|
'lg:col-span-12 lg:mx-auto lg:max-w-2xl text-center flex flex-col items-center'
|
|
)}
|
|
>
|
|
{(props.icon || props.title) && (
|
|
<div className="mb-4 flex items-center gap-3">
|
|
{props.icon && <ProductIcon icon={props.icon} />}
|
|
{props.title && (
|
|
<span
|
|
className="text-brand-600 dark:text-primary font-mono uppercase"
|
|
key={`product-name-${props.title}`}
|
|
>
|
|
{props.title}
|
|
</span>
|
|
)}
|
|
</div>
|
|
)}
|
|
<h1 className="h1 text-3xl md:text-4xl! lg:text-4xl! 2xl:text-6xl! tracking-[-.15px] text-balance">
|
|
{props.h1}
|
|
</h1>
|
|
{props.subheader && (
|
|
<div className="">
|
|
{Children.map(props.subheader, (subheader, i) => {
|
|
return (
|
|
<p className="p lg:text-lg max-w-lg lg:max-w-none text-pretty" key={i}>
|
|
{subheader}
|
|
</p>
|
|
)
|
|
})}
|
|
</div>
|
|
)}
|
|
<div className="flex flex-row md:flex-row md:items-center gap-2 mt-4">
|
|
{props.ctas?.map((cta) => {
|
|
const href = resolveDashboardCtaHref(cta.href, isLoggedIn)
|
|
return (
|
|
<Button
|
|
key={cta.href}
|
|
size="medium"
|
|
variant={cta.type ?? 'default'}
|
|
onClick={cta.onClick}
|
|
asChild
|
|
>
|
|
{isCrossZoneHref(href) ? (
|
|
<a href={href}>{cta.label ?? 'Start for free'}</a>
|
|
) : (
|
|
<Link href={href}>{cta.label ?? 'Start for free'}</Link>
|
|
)}
|
|
</Button>
|
|
)
|
|
})}
|
|
</div>
|
|
{props.footer && footerPosition === 'left' && (
|
|
<div className="ph-footer relative z-10 mt-4 md:mt-8 lg:mt-20 xl:mt-32 col-span-12">
|
|
{props.footer}
|
|
</div>
|
|
)}
|
|
</div>
|
|
{props.image && (
|
|
<div className="image-container relative min-h-[300px] col-span-12 mt-8 lg:col-span-7 lg:mt-0 xl:col-span-6 xl:col-start-7">
|
|
{props.image}
|
|
</div>
|
|
)}
|
|
{props.footer && footerPosition !== 'left' && (
|
|
<div className="relative z-10 mt-4 md:mt-8 lg:mt-20 xl:mt-32 col-span-12">
|
|
{props.footer}
|
|
</div>
|
|
)}
|
|
</SectionContainerWithCn>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default ProductHeader
|