'use client' import { StepHikeCompact } from '~/components/StepHikeCompact' import { SOURCE_FOOTER_CLASSES, SourceFrame } from '~/features/directives/CodeSample.client' import { CodeTabs } from '~/features/directives/CodeTabs.components' import { IconLinkImage } from '~/features/ui/IconLink' import { Prompt, PromptContent, PromptCopy, PromptMarkdown, PromptPanel, PromptTitle, } from '~/features/ui/PromptPanel' import { TabPanel } from '~/features/ui/Tabs' import { useSendTelemetryEvent } from '~/lib/telemetry' import { useSearchParamsShallow } from 'common' import { type DocsContentListingClickedEvent } from 'common/telemetry-constants' import { ArrowRight, ArrowUpRight, Check } from 'lucide-react' import { animate, useMotionValue, useMotionValueEvent, useReducedMotion } from 'motion/react' import Link from 'next/link' import { RadioGroup } from 'radix-ui' import { useId, useState, type ReactNode } from 'react' import { Badge, Button, cn, ToggleGroup, ToggleGroupItem } from 'ui' import { IsoShape } from 'ui-patterns/IsoShape/IsoShape' import { FLUID_RISE_MS } from 'ui-patterns/IsoShape/IsoShape.glyphs' import { CREATE_PROJECT_URL, EXPLORE_ITEMS, NEXT_STEPS, parseChoices, START_OPTIONS, type ExploreItem, } from './GettingStarted.data' import { FRAMEWORK_GROUPS, getFramework } from './GettingStarted.frameworks' import { buildPrompt } from './GettingStarted.prompts' import { useGettingStartedVariant } from './useGettingStartedVariant' interface GettingStartedVariantSwitchProps { control: ReactNode children: ReactNode } interface GettingStartedStepperClientProps { localCommandsCode: ReactNode installCodes: Record } interface StepperLink { href: string title: string groupTitle: string } interface ExploreCardProps { item: ExploreItem } interface LinkCardProps extends StepperLink { motionHandlers?: ShapeMotion['motionHandlers'] children: ReactNode } interface FeatureToggleCardProps { item: ExploreItem isSelected: boolean onFeatureToggle: (id: string) => void } interface NotchCardProps { notch: ReactNode isSelected?: boolean children: ReactNode } interface ChoiceIndicatorProps { type: 'checkbox' | 'radio' isSelected: boolean } interface FilledCheckProps { shape: 'circle' | 'square' } interface FeatureCardBodyProps { item: Pick & Partial> } interface ShapeMotion { shapeProps: { yaw: number; activation: number; fluidStep: number } motionHandlers: { onPointerEnter: () => void onPointerLeave: () => void onFocus: () => void onBlur: () => void } } interface StartChoiceCardsProps { value: string onValueChange: (value: string) => void } // builds without framework quickstarts skip the framework step const HAS_FRAMEWORKS = FRAMEWORK_GROUPS.length > 0 const FULL_TURN = Math.PI * 2 const TURN_DURATION_S = 2.4 const ACTIVATE_DURATION_S = 0.7 const toStepperLinkEvent = ({ href, title, groupTitle, }: StepperLink): DocsContentListingClickedEvent => ({ action: 'docs_content_listing_clicked', properties: { targetPath: href, linkTitle: title, groupTitle, listingId: 'getting-started-stepper', }, }) const useShapeMotion = (): ShapeMotion => { const yaw = useMotionValue(0) const activation = useMotionValue(0) const [renderedYaw, setRenderedYaw] = useState(0) const [renderedActivation, setRenderedActivation] = useState(0) const shouldReduceMotion = useReducedMotion() useMotionValueEvent(yaw, 'change', setRenderedYaw) useMotionValueEvent(activation, 'change', setRenderedActivation) const handleActivate = () => { animate(activation, 1, { duration: shouldReduceMotion ? 0 : ACTIVATE_DURATION_S, ease: 'easeOut', }) if (shouldReduceMotion) return animate(yaw, yaw.get() + FULL_TURN, { duration: TURN_DURATION_S, ease: 'linear', repeat: Infinity, }) } const handleDeactivate = () => { animate(activation, 0, { duration: shouldReduceMotion ? 0 : ACTIVATE_DURATION_S, ease: 'easeOut', }) animate(yaw, Math.round(yaw.get() / FULL_TURN) * FULL_TURN, { duration: 0.6, ease: 'easeOut', }) } return { shapeProps: { yaw: renderedYaw, activation: renderedActivation, // the glyphs move only while the shape turns fluidStep: Math.floor(renderedYaw / (FULL_TURN / ((TURN_DURATION_S * 1000) / FLUID_RISE_MS))), }, motionHandlers: { onPointerEnter: handleActivate, onPointerLeave: handleDeactivate, onFocus: handleActivate, onBlur: handleDeactivate, }, } } // flags load in the browser, so the server html and readers without javascript get the control export const GettingStartedVariantSwitch = ({ control, children, }: GettingStartedVariantSwitchProps) => { const { variant, isReady } = useGettingStartedVariant() return (
{variant === 'stepper' ? children : control}
) } export const GettingStartedStepperClient = ({ localCommandsCode, installCodes, }: GettingStartedStepperClientProps) => { const searchParams = useSearchParamsShallow() const choices = parseChoices(searchParams) const framework = getFramework(choices.fw) const isAgent = choices.start === 'agent' const setupPrompt = buildPrompt(choices.features) const sendTelemetryEvent = useSendTelemetryEvent() const [selectedGroupId, setSelectedGroupId] = useState(null) // until the reader picks a group, show the first group that holds the framework const activeGroup = FRAMEWORK_GROUPS.find((group) => group.id === selectedGroupId) ?? FRAMEWORK_GROUPS.find((group) => group.frameworks.some((item) => item.slug === choices.fw)) ?? FRAMEWORK_GROUPS[0] const handleStartChange = (start: string) => { searchParams.set('start', start) sendTelemetryEvent({ action: 'docs_getting_started_option_clicked', properties: { optionType: 'start', optionId: start }, }) } const handleFrameworkChange = (fw: string) => { searchParams.set('fw', fw) sendTelemetryEvent({ action: 'docs_getting_started_option_clicked', properties: { optionType: 'framework', optionId: fw }, }) } // an empty list means the reader skipped the step, so the prompt asks const handleFeatureToggle = (id: string) => { const wasSelected = choices.features.includes(id) searchParams.set( 'features', wasSelected ? choices.features.filter((feature) => feature !== id).join(',') : [...choices.features, id].join(',') ) sendTelemetryEvent({ action: 'docs_getting_started_option_clicked', properties: { optionType: 'feature', optionId: id, isSelected: !wasSelected }, }) } const handleQuickstartClick = () => { if (!framework) return sendTelemetryEvent( toStepperLinkEvent({ href: framework.href, title: `${framework.name} quickstart`, groupTitle: 'Connect your app', }) ) } const handleCreateProjectClick = () => sendTelemetryEvent( toStepperLinkEvent({ href: CREATE_PROJECT_URL, title: 'Create a project', groupTitle: 'Create a project', }) ) const handleGroupChange = (groupId: string) => { const group = FRAMEWORK_GROUPS.find((item) => item.id === groupId) if (!group) return setSelectedGroupId(group.id) if (!group.frameworks.some((item) => item.slug === choices.fw)) { searchParams.delete('fw') } } return (

Create a Supabase project and connect it to your app.

Let your AI agent set up Supabase, run Supabase locally, or create a hosted project.

{choices.start === 'cli' ? (

Install the Supabase CLI, initialize your project, then start the local stack. The CLI needs Node.js 20 or later, and the local stack needs Docker or another container runtime. Without a Node.js project,{' '} install the CLI for your operating system {' '} instead.

{localCommandsCode}
) : choices.start === 'dashboard' ? (

Create a hosted project in the Supabase Dashboard, then return here to connect your app.

) : null} {/* the agent reads the framework from the project, so only the manual paths ask for it */} {isAgent || !HAS_FRAMEWORKS ? null : (

Choose the framework your app uses.

{FRAMEWORK_GROUPS.map((group) => (
{group.frameworks.map((item) => ( {item.slug === choices.fw ? ( ) : ( )} {item.name} ))}
))}
)} {isAgent || !framework ? null : (

{framework.install ? `Install the client library, then follow the ${framework.name} quickstart.` : framework.sdk === 'postgres' ? `The ${framework.name} quickstart connects your app to Supabase with a Postgres connection string.` : `The ${framework.name} quickstart covers installing the client library.`}

{framework.install ? installCodes[framework.install] : null}
)} {isAgent ? (

Choose the features your app needs. If you're not sure, skip this step and let your agent help you later.

    {/* the prompt already installs the Supabase plugin, so agent mode skips that card */} {EXPLORE_ITEMS.filter((item) => item.id !== 'ai-tools').map((item) => (
  • ))}
) : null} {isAgent ? (

Your agent finds your framework, installs the Supabase CLI and the Supabase plugin, sets up a project, connects your app, then checks that your app reads data.

Agent Prompt {setupPrompt} {setupPrompt}
) : null}

Next steps

    {/* agent mode selects features in an earlier step, so these cards only link */} {isAgent ? NEXT_STEPS.map((step) => (
  • )) : EXPLORE_ITEMS.map((item) => (
  • ))}
) } const ExploreCard = ({ item }: ExploreCardProps) => { const { shapeProps, motionHandlers } = useShapeMotion() const grainId = useId().replace(/[^a-zA-Z0-9_-]/g, '') return ( {/* srgb keeps the dark fill's color. the default linear rgb shifts it toward green */} ) } const LinkCard = ({ href, title, groupTitle, motionHandlers, children }: LinkCardProps) => { const sendTelemetryEvent = useSendTelemetryEvent() const handleClick = () => sendTelemetryEvent(toStepperLinkEvent({ href, title, groupTitle })) return ( } > {children} ) } const FeatureToggleCard = ({ item, isSelected, onFeatureToggle }: FeatureToggleCardProps) => { const handleClick = () => onFeatureToggle(item.id) return ( ) } const NotchCard = ({ notch, isSelected, children }: NotchCardProps) => ( {notch} } > {children} ) const ChoiceIndicator = ({ type, isSelected }: ChoiceIndicatorProps) => { if (isSelected) return return ( ) } const FilledCheck = ({ shape }: FilledCheckProps) => ( ) const FeatureCardBody = ({ item }: FeatureCardBodyProps) => ( {item.name} {item.feature ? {item.feature} : null} {item.description} ) // the radix primitive keeps arrow key movement between the cards const StartChoiceCards = ({ value, onValueChange }: StartChoiceCardsProps) => ( {START_OPTIONS.map((option) => ( } isSelected={value === option.id} > ))} )