BETTER-AUTH. UI
Components

<AuthCard />

The <AuthCard /> component provides an interactive and customizable authentication interface that seamlessly integrates with your authentication flow. It supports multiple authentication methods, including email/password, magic links, passkey (WebAuthn), and social providers.

Usage

Here's a basic example on how to use the <AuthCard /> component within your application:

import { AuthCard } from "@daveyplate/better-auth-ui"
 
export default function AuthPage({ params }: { params: { pathname: string } }) {
    return (
        <div className="flex size-full grow flex-col items-center justify-center gap-3">
            <AuthCard pathname={params.pathname} />
        </div>
    )
}

Reference

The following props can be passed to <AuthCard /> for customization:

PropTypeDefault
className?
string
-
classNames?
AuthCardClassNames
-
callbackURL?
string
-
localization?
AuthLocalization
authLocalization
pathname?
string
-
redirectTo?
string
-
socialLayout?
"auto" | "horizontal" | "grid" | "vertical"
"auto"
view?
AuthView
-

Examples

Below are practical usage examples demonstrating common scenarios:

Specifying Initial View

You can specify the current view manually using the view prop:

<AuthCard view="signIn" />

Custom Redirect After Authentication

Customize the navigation after successful authentication using the redirectTo prop:

<AuthCard redirectTo="/dashboard" />

Localization

You can pass custom localization texts to fit different languages or contexts:

<AuthCard
    localization={{
        signIn: "Log in",
        signUp: "Register",
        magicLink: "Sign in with Email",
    }}
/>

Styling

You can thoroughly customize <AuthCard /> components using TailwindCSS utility classes and the provided classNames prop:

<AuthCard
    classNames={{
        base: "border-2 border-destructive max-w-xs",
        header: "bg-destructive/30",
        title: "text-xl text-destructive font-semibold",
        footerLink: "text-destructive hover:text-foreground",
    }}
/>

On this page