> ## Documentation Index
> Fetch the complete documentation index at: https://docs.corbado.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CorbadoConnectLogin: Seamless Passkey Login

> CorbadoConnectLogin is a UI component for passkey login. Enable smooth and secure passkey-based authentication for your users with ease.

> [card]
>
> Try Demo
>
> [Open](https://cognito.cloud.corbado-demo.com)

> [card]
>
> Talk to Adoption Engineer
>
> [Open](https://calendly.com/vincent-delitz)

> [card]
>
> Whitepaper
>
> [Open](https://www.corbado.com/passkeys/enterprise)

## 1. Introduction

**CorbadoConnectLogin** handles passkey logins. You might embed this component in a modal or on a dedicated login page. It's responsible for prompting the user to log in with a passkey and managing fallback if no passkey is available or if the passkey flow fails.

## 2. When to Use This Component

This component should be loaded at the **beginning of any login flow** where you want to offer passkeys as an authentication method.

## 3. Rendering Logic & User Experience

The component's initial appearance can vary, creating a tailored experience for the user. There are three possible scenarios when the component loads:

### 3.1 Scenario 1: Immediate Fallback

The component immediately triggers the `onFallback` callback without rendering any UI. This happens if **Gradual Rollout** rules are configured to deny passkey login for the current user. This allows you to seamlessly direct them to your existing login method (e.g., password) without showing them a passkey option they can't use.

### 3.2 Scenario 2: Standard Login Form

This is the default state. The component renders a form asking for an identifier (like an email address). In this state, the user can:

1. Type their identifier and click the button to initiate a passkey login.
2. Use **Conditional UI**, a browser feature that autofills the input with a passkey-associated account. Clicking this suggestion directly triggers the passkey login, saving the user a step.

### 3.3 Scenario 3: One-Tap Login

The component renders a "Sign in with a passkey" button for a specific user. The SDK uses remembered context, including state from previous passkey operations, to offer this path when available. The user still completes the required authenticator interaction, and your backend must verify the result.

## 4. Error Handling

The component is designed to handle errors gracefully and provide the best possible user experience. It uses two main strategies:

### 4.1 Automatic Fallback

In some cases, the component will automatically trigger the `onFallback` callback. This is the preferred behavior when:

* The user is not part of a group that is allowed to see the passkey login prompt (as determined by [Gradual Rollout](https://docs.corbado.com/corbado-connect/features/gradual-rollout.md)).
* [Passkey Intelligence](https://docs.corbado.com/corbado-connect/features/passkey-intelligence.md) determines that the user has a very low chance of successfully using a passkey (e.g., after they have provided an identifier but no passkey is associated with it).
* A critical, non-recoverable error occurs.

This prevents users from getting stuck and directs them to an alternative login method. The `errorMessage` in the callback will provide context.

### 4.2 Retryable Error Screen

In other cases, such as when a user instinctively closes the browser's passkey prompt, the error is likely recoverable. Instead of triggering the fallback, the component will display an informative message inside its own UI, explaining what happened and offering a "Try again" button. This helps guide users who might be unfamiliar with the passkey experience.

## 5. Example

```js theme={null}
<head>
  <script src="https://cdn.cloud.corbado.io/connect/dist/web-js-latest.min.js"></script>
  <link rel="stylesheet" href="https://cdn.cloud.corbado.io/connect/dist/web-js-latest.min.css" />

  <script type="module">
    const passkeyLoginElement = document.getElementById('authorize-with-passkey');
    Corbado.mountCorbadoConnectLogin(passkeyLoginElement, {
      projectId: "pro-XXX", // Your Corbado Project ID
      frontendApiUrlSuffix: "frontendapi.cloud.corbado.io", // Points to your chosen Corbado Frontend API environment

      // Optional state returned by a previous successful operation.
      clientState: localStorage.getItem('corbadoClientState') ?? undefined,

      onComplete: async (signedPasskeyData, clientState, webauthnId) => {
        // Your backend verifies the signed result and creates the session.
        // webauthnId is a lookup hint, not a verified identity on its own.
        const response = await fetch('/auth/completeLogin', {
          method: 'POST',
          headers: { 'Content-Type': 'application/json' },
          body: JSON.stringify({ signedPasskeyData }),
        });
        if (!response.ok) {
          throw new Error('Backend login verification failed');
        }
        const result = await response.json();
        if (!result.success) {
          throw new Error('Application session was not created');
        }
        // Store/use your application session as defined by your backend.
        localStorage.setItem('corbadoClientState', clientState);
      },

      // Show your existing authentication when passkey login cannot continue.
      onFallback: (identifier, errorMessage) => {
        document.getElementById('authorize-with-passkey').style.display = 'none';
        document.getElementById('authorize-with-fallback').style.display = 'block';
        // Continue your existing login, optionally prefilling identifier.
      },
    });
  </script>
</head>

<body>
  <div id="authorize-with-passkey"></div>
  <div id="authorize-with-fallback" style="display: none;">
    <!-- Your existing fallback authentication (e.g. password) comes here -->
  </div>
</body>
```

## 6. Available Configuration Parameters

The callback types below describe the SDK integration contract. See [backend setup](https://docs.corbado.com/corbado-connect/integration/generic/backend.md) for the verification endpoint used in the example.

| Name | Description | Required | Type |
| - | - | - | - |
| `onComplete` | Receives the signed result, client state and `webauthnId`. Verify the signed result on your backend before creating a session or trusting the identity. | Yes | `(signedPasskeyData: string, clientState: string, webauthnId: string) => Promise<void>` |
| `onFallback` | Show your existing login when the passkey flow cannot continue. The identifier may be empty. | Yes | `(identifier: string, errorMessage: string) => void` |
| `onFallbackSilent` | Handles fallback without an error message. If omitted, `onFallback` receives an empty message. | No | `(identifier: string) => void` |
| `onFallbackCustom` | Handles a configured custom fallback code and payload. If omitted, the code is passed to `onFallback`. | No | `(identifier: string, code: string, payload: string) => void` |
| `onUnknownUser` | Handles an unknown user in the configured flow. Keep the response consistent with your account-enumeration policy. | No | `(identifier: string) => void` |
| `onLoaded` | Reports completion of initial loading and whether initial fallback was triggered. | No | `(message: string, isFallBackTriggered: boolean) => void` |
| `onConditionalLoginStart` | Receives the controller for a conditional login request, allowing coordination with your existing form. | No | `(ac: AbortController) => void` |
| `onLoginStart` | Reports the start of a login interaction. | No | `() => void` |
| `onError` | Receives component error information. | No | `(error: string) => void` |
| `onHelpClick` | Handles the component's help action. | No | `() => void` |
| `onSignupClick` | Handles the component's sign-up action. | No | `() => void` |
| `clientState` | Optional state returned by an earlier passkey operation. Treat it as SDK state, not an application session. | No | `string` |

## 7. Customization

You can customize the component's appearance to match your application's design in two ways:

### 7.1 Through CSS Theme Variables

The easiest way to change colors, fonts, and border-radius is by overriding our CSS theme variables. You can set these in a `:root` block in your stylesheet (see the Customization section of the [CorbadoConnectAppend](https://docs.corbado.com/corbado-connect/web-ui-components/corbadoconnectappend.md) component for a full list of variables).

### 7.2 Through CSS Classes

For more detailed changes, you can directly target the component's CSS classes. All classes are scoped under the `.cb-connect-container` to avoid conflicts.

#### 7.2.1 Shared CSS Classes

These classes are used across multiple **Corbado Connect** components.

| **Class Name** | **Usage** |
| - | - |
| `.cb-h2` | Used for heading level 2 styling |
| `.cb-p` | Used for paragraph text styling |
| `.cb-bold` | Used for bold text |
| `.cb-link-button` | Used for link-style buttons |
| `.cb-connect-container` | The top-level container for the component |
| `.cb-primary-button` | Used for primary buttons |
| `.cb-secondary-button` | Used for secondary buttons |
| `.cb-notification-container` | Used for notification containers |
| `.loader` | Used for loader/spinner animations |

#### 7.2.2 Component-Specific CSS Classes

These classes are specific to the `CorbadoConnectLogin` component.

| **Class Name** | **Usage** |
| - | - |
| `.cb-login-init-signup` | Styles for the signup initialization section |
| `.cb-login-init-forgot-password` | Styles for the forgot password initialization section |
| `.cb-login-error-hard-icons` | Container for displaying hard error icons |
| `.cb-login-error-hard-fallback` | Fallback styles for hard error messages |
| `.cb-login-error-soft-icons` | Container for displaying soft error icons |
| `.cb-login-error-soft-fallback` | Fallback styles for soft error messages |
| `.cb-login-loader-container` | Container for loader elements |
| `.cb-login-init-passkey-button` | Styles for the passkey button |
| `.cb-login-error-hard-cta` | Styles for call-to-action elements in hard error |
| `.cb-login-success-icons` | Container for displaying success icons |
| `.cb-switch` | Styles for switch account button |
| `.cb-login-error-hard-help` | Styles for help messages in hard error section |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.