# SignUpForm

> Account creation with name, email and a password strength meter, then the email-code step, ending signed in.

Status: beta. Category: Auth.

```ts
import { SignUpForm } from '@glyphui/auth/ui'
```

Exports: `SignUpForm`.

## Notes

- An "email taken" error from the server shows on the email field.
- For link-based verification (Firebase), it shows "Confirm your email" instead of a code input.
- terms renders above the button, e.g. links to your terms and privacy policy.

## SignUpForm props

| Prop | Type | Default | Description |
|---|---|---|---|
| `className` | `string` |  |  |
| `collectName` | `boolean` | `true` | Ask for the user's name. Default true. |
| `description` | `ReactNode` |  |  |
| `extraFields` | `readonly SignUpExtraField[]` | `[]` | More fields your sign-up needs, such as an invite code or a workspace name. Values are validated with the form and passed to `signUp` as `extra` (the REST adapter sends them in the request body). Server errors keyed by a field's `name` show beside it. |
| `footer` | `ReactNode` |  |  |
| `headingLevel` | `HeadingLevel` |  | Heading level of the title. Default 1, for a page whose main content is the form. |
| `minPasswordLength` | `number` | `8` | Minimum password length. Default 8. |
| `onSuccess` | `((session: AuthSession) => void)` |  | Called once the account exists and the user is signed in (after the email code). |
| `providers` | `readonly OAuthProvider[]` |  |  |
| `signInHref` | `string` |  | Adds "Already have an account? Sign in" linking here. |
| `terms` | `ReactNode` |  | Shown above the button, e.g. "By signing up you agree to our Terms." |
| `title` | `ReactNode` | `Create your account` |  |

## Example: Sign up and verify

The 6-digit code arrives as a toast; it submits itself once all digits are in. ada@example.com is taken.

```tsx
import { AuthProvider } from '@glyphui/auth'
import { memoryAdapter } from '@glyphui/auth/memory'
import { SignUpForm } from '@glyphui/auth/ui'
import { Link, toast } from '@glyphui/ui'

const adapter = memoryAdapter({
  latency: 500,
  oauthProviders: ['google'],
  users: [{ email: 'ada@example.com', password: 'correct horse' }],
  onCode: ({ email, code }) => toast(`Email to ${email}`, { description: `Your code: ${code}` }),
})

export default function Example() {
  return (
    <AuthProvider adapter={adapter} syncTabs={false}>
      <SignUpForm
        headingLevel={3}
        description="Free for 14 days. No credit card required."
        signInHref="#sign-in"
        terms={
          <>
            By signing up you agree to the <Link href="#terms">Terms</Link> and{' '}
            <Link href="#privacy">Privacy Policy</Link>.
          </>
        }
        onSuccess={(session) => toast.success(`Welcome, ${session.user.name}`)}
      />
    </AuthProvider>
  )
}
```

## Example: Invite code and workspace

extraFields adds validated fields; their values reach signUp as extra, and the REST adapter sends them with the request.

```tsx
import { AuthProvider } from '@glyphui/auth'
import { memoryAdapter } from '@glyphui/auth/memory'
import { SignUpForm } from '@glyphui/auth/ui'
import { toast } from '@glyphui/ui'

const adapter = memoryAdapter({ latency: 500, requireEmailVerification: false })

export default function Example() {
  return (
    <AuthProvider adapter={adapter} syncTabs={false}>
      <SignUpForm
        headingLevel={3}
        title="Join your team"
        collectName={false}
        providers={[]}
        extraFields={[
          {
            name: 'inviteCode',
            label: 'Invite code',
            description: 'From the invitation email.',
            required: 'Enter your invite code.',
            validate: (value) =>
              /^INV-\d+$/.test(value) ? undefined : 'Codes look like INV-1234.',
          },
          { name: 'workspace', label: 'Workspace name', placeholder: 'Acme Inc.' },
        ]}
        onSuccess={(session) => toast.success(`Welcome, ${session.user.email}`)}
      />
    </AuthProvider>
  )
}
```

Live page: https://glyphui.xyz/components/sign-up-form
