import { useState, useEffect } from 'react' import { Cloud, ArrowRight, ExternalLink, Info, CheckCircle2, XCircle } from 'lucide-react' export default function VercelSync({ onMessage, authFetch }) { const [vercelToken, setVercelToken] = useState('') const [projectId, setProjectId] = useState('') const [teamId, setTeamId] = useState('') const [loading, setLoading] = useState(false) const [result, setResult] = useState(null) const [preconfig, setPreconfig] = useState(null) const apiFetch = authFetch || fetch useEffect(() => { const loadPreconfig = async () => { try { const res = await apiFetch('/admin/vercel/config') if (res.ok) { const data = await res.json() setPreconfig(data) if (data.project_id) setProjectId(data.project_id) if (data.team_id) setTeamId(data.team_id) } } catch (e) { console.error('Failed to load preconfig:', e) } } loadPreconfig() }, []) const handleSync = async () => { const tokenToUse = preconfig?.has_token && !vercelToken ? '__USE_PRECONFIG__' : vercelToken if (!tokenToUse && !preconfig?.has_token) { onMessage('error', 'Vercel Token is required') return } if (!projectId) { onMessage('error', 'Project ID is required') return } setLoading(true) setResult(null) try { const res = await apiFetch('/admin/vercel/sync', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ vercel_token: vercelToken, project_id: projectId, team_id: teamId || undefined, }), }) const data = await res.json() if (res.ok) { setResult({ ...data, success: true }) onMessage('success', data.message) } else { setResult({ ...data, success: false }) onMessage('error', data.detail || 'Sync failed') } } catch (e) { onMessage('error', 'Network error') } finally { setLoading(false) } } return (
{/* Configuration Form */}

Vercel Deployment

Sync your current key and account configuration directly to Vercel environment variables.

setVercelToken(e.target.value)} /> {preconfig?.has_token && !vercelToken && (
)}
setProjectId(e.target.value)} />

Found in Project Settings → General

setTeamId(e.target.value)} />

This will trigger a new deployment on Vercel which takes about 30-60 seconds.

{/* Status & Guide */}
{result && (
{result.success ? (
) : (
)}

{result.success ? 'Sync Successful' : 'Sync Failed'}

{result.message}

{result.deployment_url && ( )}
)}

How it works

  • 1

    Current configuration (Keys & Accounts) is exported to a JSON string.

  • 2

    The JSON is encoded to Base64 to ensure format compatibility.

  • 3

    We update the DS2API_CONFIG_JSON env variable in your Vercel project.

  • 4

    A redeployment is triggered to apply the new environment variables.

) }