Onboarding
Los primeros minutos tras registrarse: cuatro pasos cortos, una pregunta cada uno; luego el proyecto se crea frente a la persona, paso a paso, y se listan las siguientes cosas por hacer con sus botones.
import { Wizard, ProgressSteps, Checklist } from '@sypnia/ui/react'
En un computador
Recorre los cuatro pasos (solo el nombre es obligatorio), mira cómo se crea el proyecto y marca los siguientes pasos.
- Ponle nombre a tu proyecto
- Dónde viven tus datos
- Invita a tu equipo
- ¿Cómo te vas a conectar?
Ponle nombre a tu proyecto
Puedes cambiarlo después.
Va en la dirección de tu API. No se puede cambiar después.
Código
import { useEffect, useState, type ReactNode } from 'react';
import {
AuthLayout, Button, Checklist, Field, Input, LinkButton, ProgressSteps, RadioCards, RegionSelect, SkeletonOf, SlugInput, Stack, TagInput,
Wizard, slugify, useSypnia, type ProgressStep,
} from '@sypnia/ui/react';
// The first minutes after sign-up: four short steps, one question each, then the project is made in front of the
// person, step by step, and the next things to do are listed with their buttons. Only the name is required; the
// rest has a good default or can be done later.
const en = {
label: 'Set up your first project', s1: 'Name your project', name: 'Project name', nameHint: 'You can change it later.', address: 'Address', addressHint: 'Part of your API address. It cannot change later.',
noName: 'Write a name for the project.', s2: 'Where your data lives', region: 'Region', regionHint: 'Choose the one closest to your users. It cannot change later.',
s3: 'Invite your team', s3Lead: 'They get an email to join as editors. You can skip this and do it later.', emails: 'Emails', emailsAdd: 'name@company.com',
s4: 'How will you connect?', way: 'Way to connect', finish: 'Create project', making: 'Making your project', makingLead: 'This takes about a minute. You can leave this page; we will email you.',
steps: ['Creating the database', 'Setting up the API', 'Making your keys', 'Sending the invitations'],
failed: 'Setting up the API failed', failedLead: 'The database is made and kept. Try the rest again; nothing is made twice.', retry: 'Try again',
ready: (n: string) => `${n} is ready`, readyLead: 'Here is what most people do next.', next: 'Next steps', open: 'Go to the project',
todo: [
{ id: 'table', title: 'Create your first table', description: 'Or import a CSV you already have.', action: 'Create a table' },
{ id: 'agent', title: 'Connect your coding agent', description: 'Claude Code, Cursor or any MCP client.', action: 'Connect' },
{ id: 'app', title: 'Call the API from your app', description: 'Install the SDK and paste your key.', action: 'See how' },
],
ways: [
{ value: 'sdk', label: 'From my app', description: 'With the JavaScript, Python or Go SDK.', icon: 'sdk' as const },
{ value: 'agent', label: 'With a coding agent', description: 'It reads your tables and writes the queries.', icon: 'agent' as const },
{ value: 'sql', label: 'With SQL', description: 'Any Postgres client: psql, TablePlus, DBeaver.', icon: 'terminal' as const },
],
};
const es: typeof en = {
label: 'Prepara tu primer proyecto', s1: 'Ponle nombre a tu proyecto', name: 'Nombre del proyecto', nameHint: 'Puedes cambiarlo después.', address: 'Dirección', addressHint: 'Va en la dirección de tu API. No se puede cambiar después.',
noName: 'Escribe un nombre para el proyecto.', s2: 'Dónde viven tus datos', region: 'Región', regionHint: 'Elige la más cercana a tus usuarios. No se puede cambiar después.',
s3: 'Invita a tu equipo', s3Lead: 'Reciben un correo para entrar como editores. Puedes saltar esto y hacerlo después.', emails: 'Correos', emailsAdd: 'nombre@empresa.com',
s4: '¿Cómo te vas a conectar?', way: 'Forma de conectarte', finish: 'Crear proyecto', making: 'Creando tu proyecto', makingLead: 'Toma cerca de un minuto. Puedes salir de esta página; te avisamos por correo.',
steps: ['Creando la base de datos', 'Preparando la API', 'Creando tus llaves', 'Enviando las invitaciones'],
failed: 'Falló la preparación de la API', failedLead: 'La base de datos ya está creada y se guarda. Intenta de nuevo el resto; nada se crea dos veces.', retry: 'Intentar de nuevo',
ready: (n: string) => `${n} está listo`, readyLead: 'Esto es lo que la mayoría hace después.', next: 'Siguientes pasos', open: 'Ir al proyecto',
todo: [
{ id: 'table', title: 'Crea tu primera tabla', description: 'O importa un CSV que ya tengas.', action: 'Crear una tabla' },
{ id: 'agent', title: 'Conecta tu agente de código', description: 'Claude Code, Cursor o cualquier cliente MCP.', action: 'Conectar' },
{ id: 'app', title: 'Llama a la API desde tu app', description: 'Instala el SDK y pega tu llave.', action: 'Ver cómo' },
],
ways: [
{ value: 'sdk', label: 'Desde mi app', description: 'Con el SDK de JavaScript, Python o Go.', icon: 'sdk' },
{ value: 'agent', label: 'Con un agente de código', description: 'Lee tus tablas y escribe las consultas.', icon: 'agent' },
{ value: 'sql', label: 'Con SQL', description: 'Cualquier cliente de Postgres: psql, TablePlus, DBeaver.', icon: 'terminal' },
],
};
const regions = [
{ id: 'eu-west', name: 'Europe (Ireland)', location: 'Dublin' }, { id: 'us-east', name: 'United States (Virginia)', location: 'Ashburn' },
{ id: 'sa-east', name: 'South America (São Paulo)', location: 'São Paulo' },
];
export default function Onboarding({ state = 'ready' }: { state?: 'ready' | 'loading' | 'error' }) {
const { locale } = useSypnia();
const c = locale.startsWith('es') ? es : en;
const [name, setName] = useState('Northwind shop');
const [slug, setSlug] = useState('northwind-shop');
const [touchedSlug, setTouchedSlug] = useState(false);
const [region, setRegion] = useState('sa-east');
const [emails, setEmails] = useState<string[]>([]);
const [way, setWay] = useState('sdk');
const [phase, setPhase] = useState<'wizard' | 'making' | 'ready'>('wizard');
const [step, setStep] = useState(0);
const [failed, setFailed] = useState(false);
const [done, setDone] = useState<Set<string>>(new Set());
const [run, setRun] = useState(0);
useEffect(() => {
if (phase !== 'making') return;
if (failed) return;
if (step >= c.steps.length) { const t = setTimeout(() => setPhase('ready'), 500); return () => clearTimeout(t); }
const t = setTimeout(() => { if (state === 'error' && step === 1 && run === 0) setFailed(true); else setStep((s) => s + 1); }, 900);
return () => clearTimeout(t);
}, [phase, step, failed, run, state, c.steps.length]);
// Loading: while the session loads, the real wizard on its first step with its words; the two fields (filled from
// the account) wait in their own boxes.
const loading = state === 'loading';
const wait = (n: ReactNode) => (loading ? <SkeletonOf>{n}</SkeletonOf> : n);
if (phase === 'making') {
const steps: ProgressStep[] = c.steps.map((label, i) => ({ label, state: i < step ? 'done' : i === step ? (failed ? 'failed' : 'running') : 'waiting' }));
return (
<AuthLayout width="md" brandHref="#" title={failed ? c.failed : c.making} lead={failed ? c.failedLead : c.makingLead}>
<Stack gap={5}>
<ProgressSteps label={c.making} steps={steps} />
{failed && <div><Button variant="primary" icon="refresh" onClick={() => { setFailed(false); setRun((n) => n + 1); }}>{c.retry}</Button></div>}
</Stack>
</AuthLayout>
);
}
if (phase === 'ready') {
return (
<AuthLayout width="md" brandHref="#" title={c.ready(name)} lead={c.readyLead}>
<Stack gap={5}>
<Checklist title={c.next} onToggle={(id, d) => setDone((s) => { const n = new Set(s); if (d) n.add(id); else n.delete(id); return n; })}
items={c.todo.map((t) => ({ id: t.id, title: t.title, description: t.description, done: done.has(t.id), action: <LinkButton size="sm" href={`#${t.id}`}>{t.action}</LinkButton> }))} />
<div><LinkButton variant="primary" href="#project" iconEnd="arrow-right">{c.open}</LinkButton></div>
</Stack>
</AuthLayout>
);
}
return (
<AuthLayout width="md" brandHref="#">
<Wizard label={c.label} finishLabel={c.finish} onFinish={() => { setStep(0); setPhase('making'); }} steps={[
{ id: 'name', title: c.s1, validate: () => (name.trim() ? undefined : c.noName), content: (
<Stack gap={4}>
<Field label={c.name} hint={c.nameHint}>{wait(<Input value={name} onChange={(e) => { setName(e.target.value); if (!touchedSlug) setSlug(slugify(e.target.value)); }} />)}</Field>
<Field label={c.address} hint={c.addressHint}>{wait(<SlugInput prefix="api.sypnia.com/" value={slug} onChange={(s) => { setTouchedSlug(true); setSlug(s); }} />)}</Field>
</Stack>
) },
{ id: 'region', title: c.s2, content: <Field label={c.region} hint={c.regionHint}><RegionSelect regions={regions} value={region} onChange={setRegion} /></Field> },
{ id: 'team', title: c.s3, content: (
<Stack gap={3}><p>{c.s3Lead}</p><Field label={c.emails} optional><TagInput placeholder={c.emailsAdd} value={emails} onChange={setEmails} /></Field></Stack>
) },
{ id: 'way', title: c.s4, content: <RadioCards aria-label={c.way} options={c.ways} value={way} onChange={setWay} /> },
]} />
</AuthLayout>
);
} En un celular
Los mismos pasos a 390 px: el indicador de pasos se acorta y los botones comparten el ancho.
Cuando falla un paso de la creación
Termina el asistente: el paso de la API falla, el mensaje dice qué se conserva e «Intentar de nuevo» sigue desde ahí.
- Ponle nombre a tu proyecto
- Dónde viven tus datos
- Invita a tu equipo
- ¿Cómo te vas a conectar?
Ponle nombre a tu proyecto
Puedes cambiarlo después.
Va en la dirección de tu API. No se puede cambiar después.
Skeleton
El asistente real en su primer paso mientras carga la sesión; los dos campos, que se llenan desde la cuenta, esperan en sus propias cajas.
- Ponle nombre a tu proyecto
- Dónde viven tus datos
- Invita a tu equipo
- ¿Cómo te vas a conectar?
Ponle nombre a tu proyecto
Puedes cambiarlo después.
Va en la dirección de tu API. No se puede cambiar después.
Cuándo usarlo
Úsalo cuando
- Justo después de registrarse, antes de la consola: el proyecto necesita un nombre y un lugar antes que nada.
- Buenos valores por defecto en cada paso menos el nombre, para que la persona pueda pulsar Siguiente hasta el final.
No lo uses cuando
- Preguntar lo que se puede preguntar después: facturación, los roles del equipo, ajustes.
- Esconder la creación del proyecto detrás de un spinner: muestra los pasos mientras pasan.
Para todos
- El título de cada paso toma el foco cuando cambia; el indicador dice qué paso de cuántos.
- Los pasos de la creación son una lista con su estado en palabras; el que corre es el paso actual.
- Cada siguiente paso tiene su propio botón, nombrado con el paso.
Props
| Wizard | Tipo | Por defecto |
|---|---|---|
finishLabelobligatorioWhat the last button does: «Connect the database». | string | |
labelobligatorio | string | |
onFinishobligatorio | () => void | Promise<void> | |
stepsobligatorio | WizardStep[] | |
busy | boolean | |
onCancel | (() => void) |
| ProgressSteps | Tipo | Por defecto |
|---|---|---|
labelobligatorio | string | |
stepsobligatorio | ProgressStep[] |
| Checklist | Tipo | Por defecto |
|---|---|---|
itemsobligatorio | ChecklistItem[] | |
titleobligatorio | ReactNode | |
onToggle | ((id: string, done: boolean) => void) |