Files
anthony lio 22ea45a3ba feat: getting started v2 (#52511)
## Problem

* the getting started page is a stack of content listings: an overview,
use cases, framework quickstarts and tutorials
* a new reader must find a path in that list, and the page gives no
commands or agent prompt for their setup

## Solution

* adds a stepper to the getting started page, so a reader gets the steps
and an agent prompt for their setup
* adds the `docs-getting-started-v2` posthog flag, so the stepper and
the current page can run as an a/b test
* adds events for stepper choices, link clicks and prompt copies, so the
test can compare the two pages
* adds a markdown export of the stepper, so the `.md` page lists every
path for agents
* moves the iso shapes from kb into `ui-patterns`, so the docs feature
cards use the same shapes as the kb heroes
* changes the edge functions shape to a flat puzzle piece, because the
old shape had too many parts

<!-- linear:table-colwidths:397,397 -->
<table>
<thead>
<tr>
<th>state</th>
<th>preview</th>
</tr>
</thead>
<tbody>
<tr>
<td>after</td>
<td>


https://github.com/user-attachments/assets/7127d817-4240-4d08-a1c9-6ada1b1b2563

</td>
</tr>
</tbody>
</table>

## Review instructions

1. open
[/docs/guides/getting-started?docs-getting-started-v2=stepper](<https://docs-git-docs-getting-started-explorations-supabase.vercel.app/docs/guides/getting-started?docs-getting-started-v2=stepper>)
and make sure that the stepper shows with agent selected
2. select next.js and the auth card, then make sure that the setup
prompt names next.js and has a step for auth
3. open
[/docs/guides/getting-started?docs-getting-started-v2=stepper&start=cli&fw=nextjs](<https://docs-git-docs-getting-started-explorations-supabase.vercel.app/docs/guides/getting-started?docs-getting-started-v2=stepper&start=cli&fw=nextjs>)
and make sure that connect your app shows the install command and the
quickstart button

## Checklist

Check all before review:

- [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>)
2026-11-13 17:46:38 +02:00

65 lines
2.2 KiB
TypeScript

'use client'
import {
posthogClient,
useConsentState,
useFeatureFlags,
useMountEffect,
useSearchParamsShallow,
} from 'common'
import { useEffect, useState } from 'react'
type GettingStartedVariant = (typeof VARIANTS)[number]
const GETTING_STARTED_FLAG = 'docs-getting-started-v2'
const VARIANTS = ['control', 'stepper'] as const
const isVariant = (value: unknown): value is GettingStartedVariant =>
VARIANTS.some((variant) => variant === value)
// `?docs-getting-started-v2=stepper` forces a variant and records no exposure
export const useGettingStartedVariant = (): {
variant: GettingStartedVariant
isReady: boolean
} => {
const { posthog, hasLoaded } = useFeatureFlags()
const { hasAccepted } = useConsentState()
const override = useSearchParamsShallow().get(GETTING_STARTED_FLAG)
const [hasTimedOut, setHasTimedOut] = useState(false)
const [isLateForFlags, setIsLateForFlags] = useState(false)
const flagValue = posthog[GETTING_STARTED_FLAG]
// `false` means the visitor is outside the rollout, not assigned to control
const isAssigned = isVariant(flagValue)
const flagVariant: GettingStartedVariant = flagValue === 'stepper' ? 'stepper' : 'control'
// flags may never load, so the page shows after a second
useMountEffect(() => {
const timer = setTimeout(() => setHasTimedOut(true), 1000)
return () => clearTimeout(timer)
})
// the visitor already sees control, so a late flag must not swap the page or record exposure
if (hasTimedOut && !hasLoaded && !isLateForFlags) setIsLateForFlags(true)
// exception: the flag store resolves without an event to hook
useEffect(() => {
if (!isAssigned || isLateForFlags) return
// useSearchParamsShallow is empty until its own effect runs, so read the URL directly
const urlOverride = new URLSearchParams(window.location.search).get(GETTING_STARTED_FLAG)
if (isVariant(urlOverride)) return
posthogClient.captureExperimentExposure(
GETTING_STARTED_FLAG,
{ variant: flagVariant },
hasAccepted
)
}, [isAssigned, isLateForFlags, flagVariant, hasAccepted])
return {
variant: isVariant(override) ? override : isLateForFlags ? 'control' : flagVariant,
isReady: isVariant(override) || Boolean(hasLoaded) || hasTimedOut,
}
}