'use client' import { useEffect, useMemo, useRef, useState } from 'react' import Link from 'next/link' import { ArrowLeft, Check, Copy, Heart } from 'lucide-react' import { usePostHog } from 'posthog-js/react' import { isValidInviteCode, normalizeInviteCode } from '../../../lib/inviteCode' import { APP_STORE_URL, PLAY_STORE_URL, buildInviteSchemeUrl } from '../../../lib/appLinks' export function JoinClient({ code }: { code: string }) { const posthog = usePostHog() const [copied, setCopied] = useState(false) const hasAttemptedOpen = useRef(false) const isValid = isValidInviteCode(code) const normalizedCode = useMemo(() => (isValid ? normalizeInviteCode(code) : ''), [isValid, code]) // Track the page view once. Fires regardless of code validity so we can // see broken/expired links in the funnel too. useEffect(() => { posthog?.capture('join_page_viewed', { code_valid: isValid }) // eslint-disable-next-line react-hooks/exhaustive-deps }, []) // Attempt to open the app via the custom scheme once. If the app is // installed and registered for the scheme, this hands off to it; if not, // nothing visible happens and the fallback UI below remains in view. useEffect(() => { if (!isValid || hasAttemptedOpen.current) return hasAttemptedOpen.current = true window.location.href = buildInviteSchemeUrl(normalizedCode) }, [isValid, normalizedCode]) const handleCopy = async () => { try { await navigator.clipboard.writeText(normalizedCode) setCopied(true) posthog?.capture('join_page_code_copied') setTimeout(() => setCopied(false), 2000) } catch (err) { console.error('Failed to copy invite code:', err) } } const handleStoreClick = (store: 'app_store' | 'play_store') => { posthog?.capture('join_page_store_button_clicked', { store }) } if (!isValid) { return (

Invite link not recognized

This invite link looks incomplete or has expired. Ask your partner to send a new one from the Sauci app.

Back to Home
) } return (
{/* Header */}
Back to Home
{/* Content */}

You've been invited to Sauci

Open the app to pair up instantly. If it doesn't open automatically, copy your code below and enter it after you install Sauci.

Your invite code

{normalizedCode}

Don't have Sauci yet? Get the app first:

handleStoreClick('app_store')} className="btn-primary w-full sm:w-auto" > Download on the App Store handleStoreClick('play_store')} className="btn-secondary w-full sm:w-auto" > Get it on Google Play
{/* Footer */}
) }