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

# Auth

An Appstitch library for passwordless authentication

## Install&#x20;

{% tabs %}
{% tab title="JavaScript" %}

```bash
npm i @appstitch/auth
```

{% endtab %}

{% tab title="Flutter" %}

```yaml
appstitch_auth: 1.0.0
```

{% endtab %}
{% endtabs %}

Install Peer Dependencies

{% tabs %}
{% tab title="JavaScript" %}

```
npm install @appstitch/core
```

{% endtab %}

{% tab title="Flutter" %}

```yaml
appstitch_core: ^2.0.0
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Remember to initialize [Appstitch ](https://docs.appstitch.dev/)
{% endhint %}

## Usage

### Sign Up

{% tabs %}
{% tab title="JavaScript" %}

```javascript

auth.signUp({email : "test@example.com"})
    .then(result => {
        if(result.success)
        {
           // A code has been successfully sent to the email address
           // Ready to Confirm User (See below)
        }
    })
    
```

{% endtab %}

{% tab title="Flutter" %}

```dart
final opts = AuthOptions(email: "test@example.com");

final result = await auth.signUp(opts);

if(result.success!)
{
    // A code has been successfully sent to the email address
    // Ready to Confirm User (See below)
}
else
{
    // handle error
}
```

{% endtab %}
{% endtabs %}

### Sign In

{% tabs %}
{% tab title="JavaScript" %}

```javascript
auth.signIn({email : "test@example.com"})
    .then(result => {
        if(result.success)
        {
            // A code has been successfully sent to the email address
            // Ready to Confirm User (See below)
        }
    })
```

{% endtab %}

{% tab title="Flutter" %}

```dart
final opts = AuthOptions(email: "test@example.com");

final result = await auth.signUp(opts);

if(result.success!)
{
    // A code has been successfully sent to the email address        
    // Ready to Confirm User (See below)
}
else
{
    // handle error
}
```

{% endtab %}
{% endtabs %}

### Confirm User

{% tabs %}
{% tab title="JavaScript" %}

```javascript
auth.confirmUser({code : "ABC123")
    .then(result => {
        if(result.success)
        {
            // Token that can be used with other Appstitch Integrations
            const authToken = result.authToken;
            // User ID
            const id = result.id
        }
    })
```

{% endtab %}

{% tab title="Flutter" %}

```dart
final opts = AuthOptions(code: "ABC123");

final result = await auth.signUp(opts);

if(result.success!)
{
    // User ID that can be stored in your database
    const id = result.id!;
    // Token that can be used with other Appstitch Integrations
    const authToken = result.authToken!;
}
else
{
    // handle error
}
```

{% endtab %}
{% endtabs %}
