Onboarding
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.
import { Wizard, ProgressSteps, Checklist } from '@sypnia/ui/react'
On a desktop
Go through the four steps (only the name is required), watch the project being made, then tick the next steps.
- Name your project
- Where your data lives
- Invite your team
- How will you connect?
Name your project
You can change it later.
Part of your API address. It cannot change later.
Code
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>
);
} On a phone
The same steps at 390 px: the stepper shortens and the buttons share the width.
When a step of the making fails
Finish the wizard: the API step fails, the message says what is kept, and «Try again» goes on from there.
- Name your project
- Where your data lives
- Invite your team
- How will you connect?
Name your project
You can change it later.
Part of your API address. It cannot change later.
Skeleton
The real wizard on its first step while the session loads; the two fields, filled from the account, wait in their own boxes.
- Name your project
- Where your data lives
- Invite your team
- How will you connect?
Name your project
You can change it later.
Part of your API address. It cannot change later.
When to use it
Use it when
- Right after sign-up, before the console: the project needs a name and a place before anything else.
- Good defaults for every step but the name, so the person can press Next all the way.
Do not use it when
- Asking what can be asked later: billing, the team's roles, settings.
- Hiding the making of the project behind a spinner: show the steps as they happen.
For everyone
- Each step's title takes the focus when it changes; the stepper says which step of how many.
- The steps of the making are a list with their state in words; the running one is the current step.
- Every next step has its own button, named with the step.
Props
| Wizard | Type | Default |
|---|---|---|
finishLabelrequiredWhat the last button does: «Connect the database». | string | |
labelrequired | string | |
onFinishrequired | () => void | Promise<void> | |
stepsrequired | WizardStep[] | |
busy | boolean | |
onCancel | (() => void) |
| ProgressSteps | Type | Default |
|---|---|---|
labelrequired | string | |
stepsrequired | ProgressStep[] |
| Checklist | Type | Default |
|---|---|---|
itemsrequired | ChecklistItem[] | |
titlerequired | ReactNode | |
onToggle | ((id: string, done: boolean) => void) |