> For the complete documentation index, see [llms.txt](https://docs.baas.sh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.baas.sh/baas-sdk/authentication.md).

# Authentication

The SDK signs your users in two ways: with a **passkey** (the default) or with an **external wallet**. Both produce the same session.

{% hint style="info" %}
**Users own their account.** With passkeys, the account stays on their device and syncs through their password manager (iCloud Keychain, Google Password Manager, 1Password…). With external wallets, the wallet they already use is the account. This is what makes BaaS **self-custodial**.
{% endhint %}

## Which sign-in method?

{% columns %}
{% column %}

### Passkey <sub>recommended</sub>

A passkey lets users sign in with their device's built-in authentication (Face ID, Touch ID, Windows Hello, or a security key). The smoothest experience, with no crypto knowledge needed.
{% endcolumn %}

{% column %}

### External wallet

Users sign in with a wallet they already have, such as MetaMask, Rainbow, or Coinbase Wallet. Best when they're already in the wallet ecosystem and want to use their existing address.
{% endcolumn %}
{% endcolumns %}

## Sign up vs sign in

Use **sign up** for first-time users and **sign in** for returning ones. A common pattern: a **"Create account"** button that calls sign up, and a **"Sign in"** button that calls sign in.

## The `signIn` / `signUp` shortcuts

`signIn()` and `signUp()` are one-line shortcuts that default to passkeys and delegate to the explicit methods covered in [Passkeys](/baas-sdk/authentication/passkeys.md) and [External wallet](/baas-sdk/authentication/external-wallet.md). They're ideal for getting started; the explicit methods remain the canonical API when you need control.

```ts
await baas.auth.signIn();                            // passkey (default)
await baas.auth.signIn('passkey');                   // passkey (explicit)
await baas.auth.signIn('wallet', window.ethereum);   // external wallet

await baas.auth.signUp();                            // create passkey
await baas.auth.signUp('passkey');                   // create passkey (explicit)
```

| Shortcut                         | Delegates to                 |
| -------------------------------- | ---------------------------- |
| `signIn()` / `signIn('passkey')` | `signInWithPasskey()`        |
| `signIn('wallet', provider)`     | `signInWithWallet(provider)` |
| `signUp()` / `signUp('passkey')` | `signUpWithPasskey()`        |

{% hint style="info" %}
`signIn('wallet')` **requires** a provider as the second argument. Calling it without one throws a `BaasError` with code `INVALID_CONFIG`.
{% endhint %}

## Avoid double prompts

Sign-in calls run independently, so clicking a button twice opens **two** dialogs. Disable the button while a sign-in is in flight (a `pending` state) to debounce it. The [Use with React](/baas-sdk/integrations/react.md) guide shows a complete example.

## Next

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Passkeys</strong></td><td>Sign up and sign in with a device passkey.</td><td><a href="/pages/5HQy7g8eqLrblBTg8Ec8">/pages/5HQy7g8eqLrblBTg8Ec8</a></td></tr><tr><td><strong>External wallet</strong></td><td>Sign in with MetaMask, Rainbow, or any EIP-1193 wallet.</td><td><a href="/pages/KpF4ApPc9ojcoT7idI9p">/pages/KpF4ApPc9ojcoT7idI9p</a></td></tr><tr><td><strong>Sessions</strong></td><td>Read the session, listen for changes, refresh, and sign out.</td><td><a href="/pages/kgwCsZRKWwqPvCUulF9s">/pages/kgwCsZRKWwqPvCUulF9s</a></td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.baas.sh/baas-sdk/authentication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
