Skip to content
weftGitHub

SignIn

A sign-in form with passkey, single sign-on, email and password, and Forgot.

SourcePackage @weft-js/warp

Preview

tsx
import { state } from '@weft-js/core'import { AuthDone, SignIn } from '@weft-js/warp'import type { SignInValues } from '@weft-js/warp'export function Weft() {  const pending = state(false)  const who = state('')  const submit = async (values: SignInValues) => {    pending.value = true    await wait(900)    pending.value = false    who.value = values.email  }  return (    <>      {who.value        ? <AuthDone heading="h3" title="You're in" lede={`Signed in as ${who.value}.`} delay={2400} onContinue={() => (who.value = '')} />        : <SignIn heading="h3" name="weft" title="Sign in to weft" lede="Any email and password work here." providers={PROVIDERS} pending={pending.value} onSubmit={v => void submit(v)} onProvider={() => wait(900)} onPasskey={() => wait(900)} onForgot={() => {}} onMagicLink={() => {}} onSignUp={() => {}} />}    </>  )}const wait = (ms: number) => new Promise(done => { setTimeout(done, ms) })const PROVIDERS = [{ id: 'google', label: 'Google', glyph: 'M12 3a9 9 0 1 0 8.5 12H12' }, { id: 'github', label: 'GitHub', glyph: 'M9 8l-5 4 5 4M15 8l5 4-5 4' }]

Installation

npm install @weft-js/warp

Usage

tsx
import { SignIn } from '@weft-js/warp'

Wrong details

A wrong password and an unknown email read the same.

tsx
import { SignIn } from '@weft-js/warp'export function Failed() {  return (    <SignIn heading="h3" title="Sign in to weft" error="That email and password don't match." onForgot={() => {}} />  )}

When to use

Use it for

  • The screen where people come back

Reach for something else

  • SignUp, when they are new
  • ReauthDialog, when they are already in and doing something sensitive

Accessibility

  • This has no shortcuts of its own: controls inside it use Tab, Enter and Space as usual, and warp's parts keep their roles and labels.

API Reference

PropTypeDefaultDescription
titleunknown—The heading.
ledeunknown—One line under it.
logounknown—Your logo.
nameunknown—Your product's name, beside the logo.
submitLabelunknown—The main button's words.
providersSsoProvider[]—Single sign-on providers.
rememberboolean—Shows the "Keep me signed in" switch.
formFormLike—What <Form of={mutation}> gives you. The screen then renders no form of its own.
errorsRecord<string, string>—Messages by field name.
errorunknown—The failure: a string, or a typed error it can map to the right place.
errorOptionsFlowErrorOptions—Words by error code.
pendingbooleanfalseShows progress on the submit button.
headingHeading—The title's level. An auth step is usually the whole page, so h1.
EventTypeDefaultDescription
onProvider((id: string) => unknown)—Called with the provider's id.
onPasskey(() => unknown)—Shows the passkey button; run WebAuthn here.
onForgot(() => void)—Shows Forgot password.
onMagicLink((email: string) => void)—Called with the typed email; asks for one first.
onSignUp(() => void)—Shows the link to sign up.
onInvite(() => void)—Shows the link for people with an invite.
onSubmit((values: SignInValues, e: SubmitEvent) => void)—Called with the values once the screen's own checks pass.
onRetry(() => void)—The Retry on a network failure's toast.

Parts

Every element carries a stable name, so you can style it from your own CSS: [data-scope="sso"] [data-part="lede"]

lededividerrowfine

RelatedAuth screenSign upReset passwordOtp step