Skip to content

Auth

Sign-in and sign-up pages: an email card that sends a code, a magic link or both, with OAuth buttons, resend and rate-limit countdowns, and a page layout around it (centered, or split with a brand panel). No auth library inside: wire it to Better Auth, Auth.js, Supabase or your own API.

On this page
Used for
  • Sign in to a console
  • Create an account
  • Email code login
  • Magic link step
  • OAuth buttons

Examples

Auth card

Mode
Delivery
npx knowns-ui@latest add auth-card
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.
mode / onModeChange
"sign-in" | "sign-up" / (mode) => void
Default"sign-in"
Sign-up adds an optional Name field, the Create account button and `terms`. onModeChange shows the switch link under the card.
delivery
"code" | "link" | "both"
Default"code"
code: a 6-digit OtpInput step. link: a Check your inbox step with an Open Gmail/Outlook shortcut for known domains. both: the code step says a link was sent too. linkSent still works as both.
onSendCode
(email, { mode, name? }) => Promise<AuthResult>
Send the code or link. Resolve { ok: false, kind: "rate-limit", retryAfterS } to lock the form with a countdown.
onVerify
(email, code) => Promise<AuthResult>
Check the code. On { ok: true } navigate away; the card keeps its loading state meanwhile. A wrong code clears the input and shows the error.
providers
("github" | "google" | "microsoft" | "apple" | { id, label, icon? })[]
Default[]
OAuth buttons above the email form, with brand marks for the built-ins. Built-ins call onSocial, objects call onProvider.
onSocial / onProvider
(provider) => Promise<AuthResult | void>
Start the redirect. Resolve an error to show it on the card; the button spins until then.
codeLength / codeTtlMinutes / resendAfterS
number
Default6 / 10 / 30
The code size, the expiry in the copy, and the resend cooldown.
initialError / onSent / terms / footer
string / (email) => void / ReactNode / ReactNode
An error from a failed link that sent the user back; a hook after sending (e.g. a dev mail panel); the sign-up terms line; small print.
a11y
labels, live region, focus
Every field is labelled; step changes are announced; the code step focuses the first digit and the link step focuses its heading.

Auth page

Layout
npx knowns-ui@latest add auth-page
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.
variant
"centered" | "split"
Default"centered"
split puts a brand panel on the left from lg up; below that it falls back to the centered page.
logo / topRight / footer
ReactNode
Your wordmark; a link to the other mode; Terms, Privacy and Help links under the form.
aside
{ eyebrow?, headline, description?, points?, background?, bottom? }
The split panel. background takes any Backgrounds block. Keep points factual; this is not the place for quotes you can't back up.
fill
"screen" | "parent"
Default"screen"
screen is a full-height page with a <main> landmark; parent fits a container (previews, modals) without adding one.
children
ReactNode
The AuthCard, or any form.

What it handles

  1. 01Walks one card through three steps: the email field, the code step for delivery "code" or "both", and a "Check your inbox" step for delivery "link".
  2. 02Holds no auth logic: onSendCode, onVerify, onSocial and onProvider are callbacks that resolve to an AuthResult, so any backend fits.
  3. 03Turns a thrown error into a network result through settle, so the card never stays stuck in its loading state.
  4. 04Reads the result kind: a rate-limit result starts a countdown with retryAfterS, and the submit button stays disabled until it ends.
  5. 05Runs a resend countdown set by resendAfterS and labelled "Send a new code in 0:30", and verifies on its own when the code reaches codeLength digits.
  6. 06Switches to sign-up with mode, which adds an optional name field and the terms line, and offers Open Gmail or Open Outlook on the link step.

States

First render
The email step paints as it is, with focus in the email field in sign-in mode
none
Step change
The email, code and link steps swap at once and the status line announces the new step
none
Sending or verifying
The button shows its loading state and the fields are disabled
none
Resend and rate-limit countdowns
The remaining time in the label counts down by the second
every 1s, no animation
Error
The message appears under the email field or the code input
none, at once

Works with

When to use

When to use

  • A sign-in form (and sign-up) for email codes, magic links or both, with optional OAuth buttons.
  • Passwordless flows where the server decides: the card only shows its answers (errors, rate limits, countdowns).

When not to use

  • Entering a one-time code on its own, e.g. two-factor after a password: use OTP Input.
  • Password sign-in with strength rules: use Password Field.

Using with AI

Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:

  • Add the Knowns UI Auth to my app and wire it to my own data.
  • I need a sign-in form (and sign-up) for email codes, magic links or both, with optional OAuth buttons. Set that up with the Knowns UI Auth.
  • Which Auth props do I need for a minimal setup? Show me a short example.

With the server connected, your assistant calls get_component({ name: "auth-card" }) and search_docs({ query: "auth" }).

Need help?

Stuck on Auth, or found something off? We read every message.