Files
supabase/apps/www/components/Footer/index.tsx
Sean OliverandDanny White f9fd4a2a9f feat(www,docs,kb): show Do Not Sell or Share footer link to US visitors (#53490)
## Problem

US visitors need a "Do Not Sell or Share My Personal Information" footer
link, and no site reads the visitor's country
([GROWTH-1369](https://linear.app/supabase/issue/GROWTH-1369)).

## Solution

- The www proxy copies the `x-vercel-ip-country` header into a
`_sb_country` cookie, which the footers read client-side. Docs and kb
route through www, so that covers all three.
- US visitors and unknown countries see the opt-out label. Everyone else
keeps "Privacy Settings". Both open the same modal.
- The link sits on each footer's copyright line, and the label stays
hidden until the cookie is read.
- Out of scope: GPC
([GROWTH-1373](https://linear.app/supabase/issue/GROWTH-1373)) and modal
copy ([GROWTH-1370](https://linear.app/supabase/issue/GROWTH-1370)).
- Tests cover US, non-US, unknown countries, and the cookie write.
Screenshots used a hand-set cookie.

**www**

| | Before | US | DE |
|---|---|---|---|
| 375px | <img
src="https://github.com/user-attachments/assets/1bd8bcb8-6692-4fe9-90a0-5343b0364053"
width="200"> | <img
src="https://github.com/user-attachments/assets/0514a0bd-ad1c-4773-b889-de941f5466b5"
width="200"> | <img
src="https://github.com/user-attachments/assets/328ca1b4-9698-492e-8045-a15d884108f2"
width="200"> |
| 1440px | <img
src="https://github.com/user-attachments/assets/3cb3e7d7-62ab-4d34-841c-23d50d7d1cd5"
width="300"> | <img
src="https://github.com/user-attachments/assets/caf75b29-7286-404a-b1ea-7dfa5022912c"
width="300"> | <img
src="https://github.com/user-attachments/assets/2c067209-39cd-4ad8-9987-4f8763d70660"
width="300"> |

**docs**

| | Before | US | DE |
|---|---|---|---|
| 375px | <img
src="https://github.com/user-attachments/assets/37248b4a-436b-4d2d-b2d3-3966117abf9e"
width="200"> | <img
src="https://github.com/user-attachments/assets/0b109a0d-7618-46f8-ade0-8ba17e390b56"
width="200"> | <img
src="https://github.com/user-attachments/assets/0047b2b8-7047-40df-8d9c-09f51e538fa4"
width="200"> |
| 1440px | <img
src="https://github.com/user-attachments/assets/0a7d6a65-e964-43dc-911e-0ea033cb1e91"
width="300"> | <img
src="https://github.com/user-attachments/assets/27922348-661c-4246-b3fc-44ac054bd084"
width="300"> | <img
src="https://github.com/user-attachments/assets/30afb171-1023-43ff-b77e-89f341128377"
width="300"> |

**kb**

| | Before | US | DE |
|---|---|---|---|
| 375px | <img
src="https://github.com/user-attachments/assets/cd4fb8d1-8827-4b1a-8d13-c2a5d4f97378"
width="200"> | <img
src="https://github.com/user-attachments/assets/2706ae24-3df8-4149-9a51-75abb0456734"
width="200"> | <img
src="https://github.com/user-attachments/assets/7afb8731-b487-4e48-ae83-a3a6bde36bee"
width="200"> |
| 1440px | <img
src="https://github.com/user-attachments/assets/3b2bdc17-fee7-4ec0-bd24-d35a0367a6ca"
width="300"> | <img
src="https://github.com/user-attachments/assets/479b03e6-6890-4714-bbbb-ab122f46e786"
width="300"> | <img
src="https://github.com/user-attachments/assets/252f4e0f-5bcc-4b43-aeda-784df9f000ca"
width="300"> |

## Review instructions

1. From a US IP, click the footer link on the www preview. The modal
opens.
2. From a non-US IP, see "Privacy Settings".

## Checklist

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)

---------

Co-authored-by: Danny White <3104761+dnywh@users.noreply.github.com>
2026-11-20 16:44:17 +09:00

284 lines
10 KiB
TypeScript

'use client'
import { CheckIcon } from '@heroicons/react/outline'
import { REALTIME_CHANNEL_STATES } from '@supabase/supabase-js'
import SupabaseWordmark from '~/components/Nav/SupabaseWordmark'
import supabase from '~/lib/supabase'
import footerData from 'data/Footer'
import Link from 'next/link'
import { usePathname } from 'next/navigation'
import { FormEvent, useEffect, useState } from 'react'
import {
Badge,
Button,
cn,
IconDiscord,
IconGitHubSolid,
IconInstagram,
IconTikTok,
IconTwitterX,
IconYoutubeSolid,
Input,
} from 'ui'
import { PrivacySettings, PrivacySettingsLabel } from 'ui-patterns/PrivacySettings'
import { ThemeToggle } from 'ui-patterns/ThemeToggle'
import useDarkLaunchWeeks from '../../hooks/useDarkLaunchWeeks'
import SectionContainer from '../Layouts/SectionContainer'
import { isCrossZoneHref } from '@/lib/cross-zone'
interface Props {
className?: string
hideFooter?: boolean
}
const Footer = (props: Props) => {
const pathname = usePathname()
const [newsletterEmail, setNewsletterEmail] = useState('')
const [newsletterStatus, setNewsletterStatus] = useState<
'idle' | 'loading' | 'success' | 'error'
>('idle')
const handleNewsletterSubmit = async (e: FormEvent) => {
e.preventDefault()
if (!newsletterEmail) return
setNewsletterStatus('loading')
try {
const res = await fetch('/api-v2/submit-form-newsletter', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email: newsletterEmail }),
})
if (!res.ok) throw new Error()
setNewsletterStatus('success')
} catch {
setNewsletterStatus('error')
}
}
const isDarkLaunchWeek = useDarkLaunchWeeks()
const isGAWeek = pathname?.includes('/ga-week')
const forceDark = isDarkLaunchWeek
useEffect(() => {
const channel = supabase.channel('footer')
if (channel.state === REALTIME_CHANNEL_STATES.closed) {
channel.subscribe()
}
return () => {
channel.unsubscribe()
}
}, [])
if (props.hideFooter) {
return null
}
return (
<footer
className={cn(
'bg-alternative',
isDarkLaunchWeek && 'bg-[#060809]',
isGAWeek && 'dark:bg-alternative',
props.className
)}
>
<h2 id="footerHeading" className="sr-only">
Footer
</h2>
<div className="w-full py-0!">
<SectionContainer className="grid grid-cols-2 md:flex items-center justify-between text-foreground md:justify-center gap-8 md:gap-16 xl:gap-28 py-6! md:py-10! text-sm">
<div className="flex flex-col md:flex-row gap-2 md:items-center">
We protect your data.
<Link href="/security" className="text-primary hover:underline">
More on Security
</Link>
</div>
<ul className="flex flex-col md:flex-row gap-2 md:gap-8 justify-center md:items-center">
<li className="flex items-center gap-2 whitespace-nowrap flex-nowrap">
<CheckIcon className="w-4 h-4" /> SOC2 Type 2{' '}
<span className="text-foreground-lighter hidden sm:inline">Certified</span>
</li>
<li className="flex items-center gap-2 whitespace-nowrap flex-nowrap">
<CheckIcon className="w-4 h-4" /> HIPAA{' '}
<span className="text-foreground-lighter hidden sm:inline">Compliant</span>
</li>
<li className="flex items-center gap-2 whitespace-nowrap flex-nowrap">
<CheckIcon className="w-4 h-4" /> ISO 27001{' '}
<span className="text-foreground-lighter hidden sm:inline">Certified</span>
</li>
</ul>
</SectionContainer>
<div className="w-full h-px bg-linear-to-r from-transparent via-border to-transparent" />
</div>
<SectionContainer className="py-8">
<div className="xl:grid xl:grid-cols-7 xl:gap-4">
<div className="xl:col-span-2 flex flex-col gap-8">
<Link href="#" as="/" className="w-40">
<SupabaseWordmark className="w-40 h-[30px]" />
</Link>
<div className="flex space-x-5">
<a
target="_blank"
rel="noopener noreferrer"
href="https://twitter.com/supabase"
className="text-foreground-lighter hover:text-foreground transition"
>
<span className="sr-only">Twitter</span>
<IconTwitterX size={22} />
</a>
<a
target="_blank"
rel="noopener noreferrer"
href="https://github.com/supabase"
className="text-foreground-lighter hover:text-foreground transition"
>
<span className="sr-only">GitHub</span>
<IconGitHubSolid size={22} />
</a>
<a
target="_blank"
rel="noopener noreferrer"
href="https://discord.supabase.com/"
className="text-foreground-lighter hover:text-foreground transition"
>
<span className="sr-only">Discord</span>
<IconDiscord size={22} />
</a>
<a
target="_blank"
rel="noopener noreferrer"
href="https://youtube.com/c/supabase"
className="text-foreground-lighter hover:text-foreground transition"
>
<span className="sr-only">Youtube</span>
<IconYoutubeSolid size={22} />
</a>
<a
target="_blank"
rel="noopener noreferrer"
href="https://www.tiktok.com/@supabase.com"
className="text-foreground-lighter hover:text-foreground transition"
>
<span className="sr-only">TikTok</span>
<IconTikTok size={22} />
</a>
<a
target="_blank"
rel="noopener noreferrer"
href="https://www.instagram.com/supabasecom"
className="text-foreground-lighter hover:text-foreground transition"
>
<span className="sr-only">Instagram</span>
<IconInstagram size={22} />
</a>
</div>
<div>
{newsletterStatus === 'success' ? (
<div className="flex flex-col gap-1">
<p className="text-primary text-sm">Thanks for subscribing!</p>
<p className="text-foreground-lighter text-xs">
You'll hear from us when we publish our next newsletter issue.
</p>
</div>
) : (
<form onSubmit={handleNewsletterSubmit} className="flex flex-col gap-2">
<p className="text-foreground-lighter text-sm">
Get product updates and news from Supabase.
</p>
<Input
type="email"
placeholder="Your email"
aria-label="Email for newsletter"
value={newsletterEmail}
onChange={(e) => setNewsletterEmail(e.target.value)}
required
className="flex-1 md:max-w-72 xl:max-w-[80%] h-6! text-xs px-2"
/>
<Button
variant="primary"
size="tiny"
type="submit"
loading={newsletterStatus === 'loading'}
className="w-fit"
>
Subscribe
</Button>
</form>
)}
{newsletterStatus === 'error' && (
<p className="text-destructive text-sm mt-2">Something went wrong. Try again.</p>
)}
</div>
</div>
<div className="mt-12 grid grid-cols-1 gap-8 xl:col-span-5 xl:mt-0">
<div className="grid grid-cols-2 gap-x-4 gap-y-12 md:grid-cols-3 xl:grid-cols-6">
{footerData.map((segment) => {
return (
<div key={`footer_${segment.title}`}>
<h6 className="text-foreground overwrite text-base">{segment.title}</h6>
<ul className="mt-4 space-y-2">
{segment.links.map((link, idx) => {
const children = (
<div
className={`text-sm transition-colors ${
link.url
? 'text-foreground-lighter hover:text-foreground'
: 'text-muted hover:text-foreground-lighter'
} `}
>
{link.text}
{!link.url && (
<div className="ml-2 inline text-xs xl:ml-0 xl:block 2xl:ml-2 2xl:inline">
<Badge>Coming soon</Badge>
</div>
)}
</div>
)
return (
<li key={`${segment.title}_link_${idx}`}>
{link.url ? (
link.url.startsWith('https') || isCrossZoneHref(link.url) ? (
<a href={link.url}>{children}</a>
) : (
<Link href={link.url}>{children}</Link>
)
) : (
children
)}
</li>
)
})}
</ul>
</div>
)
})}
</div>
</div>
</div>
<div className="border-default mt-32 flex justify-between border-t pt-8">
<div className="flex flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-3">
<small className="small">&copy; Supabase Inc</small>
<span className="small hidden sm:inline">—</span>
<PrivacySettings className="small text-left hover:underline">
<PrivacySettingsLabel />
</PrivacySettings>
</div>
<div className={cn(forceDark && 'hidden')}>
<ThemeToggle forceDark={forceDark} />
</div>
</div>
</SectionContainer>
</footer>
)
}
export default Footer