Auth Components

6 Components

Pre-built, customizable authentication components. Drop-in UI for sign-in, sign-up, user profiles, and security settings.

Quick Start

All auth components are available from the SDK. Wrap your app with SylphxProvider for automatic auth context.
Installation
import {
  SignInForm,
  SignUpForm,
  UserProfile,
  SecuritySettings,
  AccountSection,
  OAuthButtons,
} from '@sylphx/platform-sdk/react'

SignInForm

A complete sign-in form with email/password authentication, OAuth provider buttons, and forgot password link. Handles validation, loading states, and error messages automatically.

Accessible
Themeable
Basic Usage
import { SignInForm } from '@sylphx/platform-sdk/react'

export default function LoginPage() {
  return (
    <div className="flex min-h-screen items-center justify-center">
      <SignInForm
        onSuccess={(user) => {
          console.log('Signed in:', user.email)
          // Redirect handled automatically, or customize:
          // router.push('/dashboard')
        }}
        onError={(error) => {
          console.error('Sign in failed:', error.message)
        }}
      />
    </div>
  )
}

Props

PropertyTypeDescription
onSuccess(user: User) => voidCallback fired after successful sign-in
onError(error: AuthError) => voidCallback fired on authentication error
redirectUrlstring= /dashboardURL to redirect after sign-in
providersOAuthProvider[]= ["google", "github"]OAuth providers to display
showForgotPasswordboolean= trueShow forgot password link
showSignUpLinkboolean= trueShow sign-up link
signUpUrlstring= /signupURL for sign-up link
forgotPasswordUrlstring= /forgot-passwordURL for forgot password
titlestring= "Welcome back"Form title
descriptionstringForm description text
themeThemeVariablesCustom theme overrides
classNamestringAdditional CSS classes

Advanced Examples

<SignInForm
  providers={['google', 'github', 'apple', 'discord']}
  title="Sign in to your account"
  description="Choose your preferred method"
/>

SignUpForm

User registration form with email verification, password strength indicator, and terms acceptance. Supports OAuth signup and custom fields.

Email Verification
Password Strength
Basic Usage
import { SignUpForm } from '@sylphx/platform-sdk/react'

export default function RegisterPage() {
  return (
    <div className="flex min-h-screen items-center justify-center">
      <SignUpForm
        onSuccess={(user) => {
          // User created, email verification sent
          router.push('/verify-email')
        }}
        requireEmailVerification={true}
      />
    </div>
  )
}

Props

PropertyTypeDescription
onSuccess(user: User) => voidCallback fired after successful registration
onError(error: AuthError) => voidCallback fired on registration error
redirectUrlstring= /verify-emailURL to redirect after sign-up
providersOAuthProvider[]= ["google", "github"]OAuth providers for social signup
requireEmailVerificationboolean= trueRequire email verification
showTermsCheckboxboolean= trueShow terms acceptance checkbox
termsUrlstring= /termsURL to terms of service
privacyUrlstring= /privacyURL to privacy policy
showPasswordStrengthboolean= trueShow password strength indicator
minPasswordLengthnumber= 8Minimum password length
showSignInLinkboolean= trueShow sign-in link
signInUrlstring= /loginURL for sign-in link
titlestring= "Create an account"Form title
themeThemeVariablesCustom theme overrides
classNamestringAdditional CSS classes

Advanced Examples

<SignUpForm
  additionalFields={[
    {
      name: 'fullName',
      label: 'Full Name',
      type: 'text',
      required: true,
      placeholder: 'John Doe',
    },
    {
      name: 'company',
      label: 'Company',
      type: 'text',
      required: false,
      placeholder: 'Acme Inc.',
    },
  ]}
  onSuccess={(user, formData) => {
    console.log('Custom fields:', formData.fullName, formData.company)
  }}
/>

Email Verification

When requireEmailVerification is enabled, users will receive a verification email and must confirm before accessing protected routes.

UserProfile

A complete user profile management component with avatar upload, name editing, and email management. Handles all profile update operations automatically.

Avatar Upload
Email Change
Basic Usage
import { UserProfile } from '@sylphx/platform-sdk/react'

export default function SettingsPage() {
  return (
    <div className="max-w-2xl mx-auto py-8">
      <h1 className="text-2xl font-bold mb-6">Profile Settings</h1>
      <UserProfile
        onUpdate={(user) => {
          toast.success('Profile updated!')
        }}
      />
    </div>
  )
}

Props

PropertyTypeDescription
onUpdate(user: User) => voidCallback fired after profile update
onError(error: Error) => voidCallback fired on update error
showAvatarboolean= trueShow avatar upload section
showEmailboolean= trueShow email field
showNameboolean= trueShow name fields
allowEmailChangeboolean= trueAllow users to change email
avatarUploadUrlstringCustom avatar upload endpoint
maxAvatarSizenumber= 5242880Max avatar file size in bytes
acceptedImageTypesstring[]= ["image/jpeg", "image/png", "image/webp"]Accepted image MIME types
customFieldsCustomField[]Additional profile fields to display
layout"card" | "flat"= "card"Visual layout style
themeThemeVariablesCustom theme overrides
classNamestringAdditional CSS classes

Advanced Examples

<UserProfile
  customFields={[
    {
      name: 'bio',
      label: 'Bio',
      type: 'textarea',
      placeholder: 'Tell us about yourself...',
      maxLength: 500,
    },
    {
      name: 'website',
      label: 'Website',
      type: 'url',
      placeholder: 'https://yoursite.com',
    },
    {
      name: 'timezone',
      label: 'Timezone',
      type: 'select',
      options: [
        { value: 'UTC', label: 'UTC' },
        { value: 'America/New_York', label: 'Eastern Time' },
        { value: 'America/Los_Angeles', label: 'Pacific Time' },
        { value: 'Europe/London', label: 'London' },
      ],
    },
  ]}
/>

SecuritySettings

Security management component with password change, two-factor authentication setup, and session management. Handles all security operations securely.

Password
2FA Setup
Basic Usage
import { SecuritySettings } from '@sylphx/platform-sdk/react'

export default function SecurityPage() {
  return (
    <div className="max-w-2xl mx-auto py-8">
      <h1 className="text-2xl font-bold mb-6">Security</h1>
      <SecuritySettings
        onPasswordChange={() => {
          toast.success('Password updated successfully!')
        }}
        on2FAEnabled={() => {
          toast.success('Two-factor authentication enabled!')
        }}
      />
    </div>
  )
}

Props

PropertyTypeDescription
onPasswordChange() => voidCallback fired after password change
on2FAEnabled() => voidCallback fired when 2FA is enabled
on2FADisabled() => voidCallback fired when 2FA is disabled
onSessionRevoked(sessionId: string) => voidCallback fired when a session is revoked
onError(error: Error) => voidCallback fired on any error
showPasswordSectionboolean= trueShow password change section
show2FASectionboolean= trueShow 2FA setup section
showSessionsSectionboolean= trueShow active sessions section
showLoginHistoryboolean= falseShow recent login history
require2FAboolean= falseRequire 2FA (hide disable option)
minPasswordLengthnumber= 8Minimum password length
requireCurrentPasswordboolean= trueRequire current password for changes
themeThemeVariablesCustom theme overrides
classNamestringAdditional CSS classes

Advanced Examples

<SecuritySettings
  showPasswordSection={true}
  show2FASection={true}
  showSessionsSection={true}
  showLoginHistory={true}
  onPasswordChange={() => {
    // Log security event
    analytics.track('password_changed')
    toast.success('Password changed!')
  }}
  on2FAEnabled={() => {
    analytics.track('2fa_enabled')
  }}
  onSessionRevoked={(sessionId) => {
    analytics.track('session_revoked', { sessionId })
    toast.success('Session revoked')
  }}
/>

Security Best Practice

Always require the current password (requireCurrentPassword=true) when allowing users to change their password or security settings.

AccountSection

Account management component with connected accounts, data export, and account deletion. Includes a danger zone for destructive actions with confirmation dialogs.

Connected Accounts
Danger Zone
Basic Usage
import { AccountSection } from '@sylphx/platform-sdk/react'

export default function AccountPage() {
  return (
    <div className="max-w-2xl mx-auto py-8">
      <h1 className="text-2xl font-bold mb-6">Account</h1>
      <AccountSection
        onAccountDeleted={() => {
          // Redirect to goodbye page
          router.push('/goodbye')
        }}
        onDataExportRequested={() => {
          toast.success('Data export started. You\'ll receive an email when ready.')
        }}
      />
    </div>
  )
}

Props

PropertyTypeDescription
onAccountDeleted() => voidCallback fired after account deletion
onDataExportRequested() => voidCallback fired when data export is requested
onAccountConnected(provider: string) => voidCallback when OAuth account is connected
onAccountDisconnected(provider: string) => voidCallback when OAuth account is disconnected
onError(error: Error) => voidCallback fired on any error
showConnectedAccountsboolean= trueShow connected OAuth accounts
showDataExportboolean= trueShow data export option
showDangerZoneboolean= trueShow danger zone with delete account
allowAccountDeletionboolean= trueAllow users to delete their account
deletionCooldownnumber= 30Days before account is permanently deleted
requirePasswordForDeletionboolean= trueRequire password to delete account
availableProvidersOAuthProvider[]= ["google", "github", "apple"]OAuth providers available for connection
themeThemeVariablesCustom theme overrides
classNamestringAdditional CSS classes

Advanced Examples

<AccountSection
  showConnectedAccounts={true}
  showDataExport={false}
  showDangerZone={false}
  availableProviders={['google', 'github', 'apple', 'discord']}
  onAccountConnected={(provider) => {
    toast.success(`Connected ${provider} account`)
  }}
  onAccountDisconnected={(provider) => {
    toast.success(`Disconnected ${provider} account`)
  }}
/>

Account Deletion

Account deletion is permanent. The deletionCooldown prop allows a grace period where users can cancel the deletion.

OAuthButtons

Standalone OAuth provider buttons for social login. Use when you need more control over the sign-in UI or want to place OAuth buttons separately from the main form.

9+ Providers
Customizable
Basic Usage
import { OAuthButtons } from '@sylphx/platform-sdk/react'

export default function LoginPage() {
  return (
    <div className="max-w-md mx-auto py-8">
      <h1 className="text-2xl font-bold mb-6">Sign In</h1>

      <OAuthButtons
        providers={['google', 'github', 'apple']}
        onSuccess={(user, provider) => {
          console.log(`Signed in with ${provider}`)
          router.push('/dashboard')
        }}
      />

      <div className="relative my-6">
        <div className="absolute inset-0 flex items-center">
          <div className="w-full border-t" />
        </div>
        <div className="relative flex justify-center text-sm">
          <span className="bg-background px-2 text-muted-foreground">
            Or continue with email
          </span>
        </div>
      </div>

      {/* Your custom email form here */}
    </div>
  )
}

Props

PropertyTypeDescription
providersrequiredOAuthProvider[]OAuth providers to display
onSuccess(user: User, provider: string) => voidCallback fired after successful OAuth
onError(error: AuthError, provider: string) => voidCallback fired on OAuth error
redirectUrlstring= /dashboardURL to redirect after OAuth
mode"signin" | "signup" | "connect"= "signin"OAuth flow mode
layout"vertical" | "horizontal" | "grid"= "vertical"Button layout
variant"default" | "outline" | "ghost"= "default"Button variant style
size"sm" | "md" | "lg"= "md"Button size
showLabelsboolean= trueShow provider name labels
iconOnlyboolean= falseShow only icons (no text)
disabledboolean= falseDisable all buttons
loadingstring | nullProvider currently loading
scopesRecord<string, string[]>Custom scopes per provider
themeThemeVariablesCustom theme overrides
classNamestringAdditional CSS classes

Supported Providers

google
github
apple
discord
twitter
facebook
microsoft
linkedin
spotify

Advanced Examples

<OAuthButtons
  providers={['google', 'github', 'apple']}
  layout="horizontal"
  variant="outline"
  size="lg"
/>

Theming

All auth components support theming via the theme prop. Customize colors, fonts, and border radius to match your brand.

Custom Theme
import { SignInForm, defaultTheme, type ThemeVariables } from '@sylphx/platform-sdk/react'

const customTheme: ThemeVariables = {
  ...defaultTheme,
  colorPrimary: '#6366f1',
  colorPrimaryHover: '#4f46e5',
  colorBackground: '#ffffff',
  colorForeground: '#1f2937',
  colorMuted: '#f3f4f6',
  colorMutedForeground: '#6b7280',
  colorBorder: '#e5e7eb',
  colorInput: '#ffffff',
  colorDestructive: '#ef4444',
  colorSuccess: '#22c55e',
  fontFamily: 'Inter, sans-serif',
  fontSize: '14px',
  borderRadius: '0.75rem',
  shadowSm: '0 1px 2px 0 rgb(0 0 0 / 0.05)',
  shadowMd: '0 4px 6px -1px rgb(0 0 0 / 0.1)',
}

<SignInForm theme={customTheme} />
<SignUpForm theme={customTheme} />
<UserProfile theme={customTheme} />
PropertyTypeDescription
colorPrimarystring= #000000Primary brand color
colorPrimaryHoverstring= #1f2937Primary color on hover
colorBackgroundstring= #ffffffComponent background
colorForegroundstring= #1f2937Primary text color
colorMutedstring= #f3f4f6Muted background
colorMutedForegroundstring= #6b7280Secondary text color
colorBorderstring= #e5e7ebBorder color
colorDestructivestring= #ef4444Error/destructive color
colorSuccessstring= #22c55eSuccess color
fontFamilystring= system-uiFont family
borderRadiusstring= 0.5remBorder radius

Best Practices

Use SylphxProvider

Wrap your app with SylphxProvider for automatic auth context and session management.

Handle Errors Gracefully

Always provide onError callbacks to show user-friendly error messages.

Customize Carefully

When theming, ensure sufficient color contrast for accessibility.

Secure by Default

Enable requireEmailVerification and requireCurrentPassword for sensitive operations.

Need more customization?

Use the auth hooks for fully custom UI while keeping all the security benefits.