> For the complete documentation index, see [llms.txt](https://simpleaswater.gitbook.io/dappkit/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://simpleaswater.gitbook.io/dappkit/dappauth.md).

# DappAuth

![Example desktop wallet select modal](/files/-LvWykXRm5F3O1dkACdf)

![Example mobile wallet select modal](/files/-LvWyqd8v144rspkU8sP)

## Quickstart

It should take less than 5 minutes to get going with DappAuth module.

### **Create a Dappkit Account**

Go to the Account Dashboard at <https://dappkit.io/signup> and setup an account with an email address.

### **Create a New Project**

After creating a new Dappkit account, you will be the directed to a new page. Here you can create a new Dappkit project by clicking "Create a Project" button.

![Create a new Dappkit Project](/files/-LvX-iQso1BPNXAY29dx)

On clicking the button, you will be asked to enter a project name, which needs to be at least 4 characters long.&#x20;

After that you will be directed to the Dappkit console.

### **Getting the Project ID**

In the Dappkit console *authentication* section, you can see your *Project ID.*

![Example ProjectID in authentication section of Dappkit console](/files/-LvX1ZJ4rfNayODytvVi)

This *Project ID* works as an API key for your project.

### **Install the widget using npm**

```bash
npm install dappauth --save
```

### **Initialize the Library**

Use the minimum required config. There are more options available as detailed in the [initialization](broken://pages/-Lp-SU_ebjderDpdnKDX#initialization) section.

```javascript
import DappAuth from 'dappauth'

const modules = DappAuth.modules({
    // [String] The Project ID created by the above step
    projectId: 'FpYyElS5Dkw7ulgc',

    // [Boolean]  Opt-in light analytics 
    allowAuthAnalytics: true
})

const { dapper, metamask, trust, coinbase } = modules.select

// initialize onboard
const dappauth = DappAuth.init({
    networkId: 1,
    subscriptions: {
        network: network => console.log("user network has changed:", network),
        address: address => console.log("user address has changed:", address),
        balance: balance => console.log("user balance has changed:", balance),
        wallet: wallet =>
            console.log(
                "a new wallet has been selected by user",
                wallet.provider,
                wallet.name
            )
    },
    modules: {
        // default wallets that are included: MetaMask, Dapper, Coinbase, Trust, WalletConnect, Torus
        walletSelect: {
            heading: "Select a Wallet",
            description:
                "Please select the wallet that you would like to use with this Dapp",
            wallets: {
                desktop: [
                    dapper(),
                    metamask()
                ],
                mobile: [
                    trust(),
                    coinbase()
                ]
            }
        },
        // default ready steps are: connect, network, balance
        walletReady: modules.ready.defaults({
            networkId: 4,
            minimumBalance: "200000000000000000"
        })
    }
})
```

The wallet subscription function will be called when the user selects a wallet so you can instantiate web3 with the selected provider.

{% hint style="info" %}
Following parameters are recorded in the analytics:

* user public address
* auth method used to signup/login(eg. metamask)
* date-time of sessions

**DEVELOPER CONSENT**

If *"allowAuthAnalytics"* is set to "true", then you can see the list of the on-boarded users in the "Authentication" section of your project dashboard.

If *"allowAuthAnalytics"* is set to "false", **NO** data will be recorded.

**USER CONSENT (to be added soon)**

While logging in, the user will be asked if he/she wants to participate in the analytics or not. If approved, **ONLY** then the data can be recorded.
{% endhint %}

### **On-board User**

Ask the user to select a wallet and then check wallet is ready to transact.

```javascript
await dappauth.walletSelect();
await dappauth.walletCheck();
```

### **And you are live!**

![Sample on-board modal](/files/-LvaOC79XVjvnInDHrU2)
