# @web3-onboard/web3auth

> Web3Auth SDK wallet module for connecting to Web3-Onboard. Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, framework agnostic moder

Latest version **2.4.0** (published 2024-06-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @web3-onboard/web3auth
pnpm add @web3-onboard/web3auth
yarn add @web3-onboard/web3auth
bun add @web3-onboard/web3auth
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.4.0 |
| Published | 2024-06-24 |
| First published | 2022-06-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 16.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 923 |
| Keywords | Ethereum, Web3, EVM, dapp, Multichain, Wallet, Transaction, Provider, Hardware Wallet, Notifications, React, Svelte, Vue, Next, Nuxt, MetaMask, Coinbase, WalletConnect, Ledger, Trezor, Connect Wallet, Ethereum Hooks, Blocknative, Mempool, pending, confirmed, Injected Wallet |

## Links

- npm: https://www.npmjs.com/package/@web3-onboard/web3auth
- Repository: https://github.com/blocknative/web3-onboard
- Homepage: https://onboard.blocknative.com
- Issues: https://github.com/blocknative/web3-onboard/issues
- npm.io page: https://npm.io/package/@web3-onboard/web3auth

## Dependencies (5)

- [react-dom](https://npm.io/package/react-dom.md) ^18.2.0
- [@web3auth/base](https://npm.io/package/@web3auth/base.md) ^8.6.2
- [@solana/web3.js](https://npm.io/package/@solana/web3.js.md) ^1.73.0
- [@web3auth/modal](https://npm.io/package/@web3auth/modal.md) ^8.6.2
- [@web3-onboard/common](https://npm.io/package/@web3-onboard/common.md) ^2.4.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 2.4.0 (latest) — 2024-06-24
- 2.4.0-alpha.2 (next) — 2024-06-14
- 2.4.0-alpha.1 — 2024-06-13
- 2.3.1 — 2024-06-05
- 2.3.0 — 2024-05-31
- 2.3.0-alpha.2 — 2024-05-28
- 2.3.0-wagmi.2 — 2024-05-23
- 2.3.0-wagmi.1 — 2024-05-17
- 2.3.0-viem.1 — 2024-05-13
- 2.2.3 — 2023-05-19
- 2.2.3-alpha.1 — 2023-05-19
- 2.2.2 — 2023-05-11
- 2.2.2-alpha.2 — 2023-05-10
- 2.2.1 — 2023-04-07
- 2.2.1-alpha.1 — 2023-04-06
- … 27 more at https://npm.io/package/@web3-onboard/web3auth/versions

## README

# @web3-onboard/web3auth

## Wallet module for connecting Web3auth to web3-onboard

### Install

`npm i @web3-onboard/core @web3-onboard/web3auth`

## Options

See the [Web3auth Docs](https://docs.web3auth.io/api-reference/web/plugnplay) for the extensive list of options.
For troubleshooting web3Auth errors, framework, polyfill, etc please see the [official Web3Auth troubleshooting docs](https://web3auth.io/docs/troubleshooting/webpack-issues).

## Usage

```typescript
import Onboard from '@web3-onboard/core'
import web3authModule from '@web3-onboard/web3auth'
import { EthereumPrivateKeyProvider } from '@web3auth/ethereum-provider'
import { CHAIN_NAMESPACES } from '@web3auth/base'

const privateKeyProvider = new EthereumPrivateKeyProvider({
  config: {
    chainConfig: {
      chainId: `0xAA36A7`,
      rpcTarget: `https://rpc.sepolia.org/`,
      chainNamespace: CHAIN_NAMESPACES.EIP155,
      displayName: 'Sepolia',
      blockExplorerUrl: 'https://sepolia.etherscan.io',
      ticker: 'ETH',
      tickerName: 'Ether',
      logo: 'https://images.toruswallet.io/ethereum.svg'
    }
  }
})

// must access via http://localhost:8080 to be whitelisted
const web3auth = web3authModule({
  clientId:
    'BErDmyuxFPtpvM_Isiy8RHNWOWYvkAUehrgmO0rDoe5yr33ixt5s98eT_qePTyRsgpN7SVQwrEUMx7gON0jBDQI',
  privateKeyProvider: privateKeyProvider,
  web3AuthNetwork: 'sapphire_devnet'
})

const onboard = Onboard({
  // ... other Onboard options
  wallets: [
    web3auth
    //... other wallets
  ]
})

const connectedWallets = await onboard.connectWallet()
console.log(connectedWallets)
```

## Types

```typescript
import type { Web3AuthOptions, ModalConfig } from '@web3auth/modal'
import type { CustomChainConfig, OPENLOGIN_NETWORK_TYPE } from '@web3auth/base'

type Web3AuthModuleOptions = Omit<Web3AuthOptions, 'chainConfig'> & {
  chainConfig?: Partial<CustomChainConfig> &
    Pick<CustomChainConfig, 'chainNamespace'>
  modalConfig?: Record<string, ModalConfig> | undefined
  /**
   * Web3Auth Network to use for the session & the issued idToken
   */
  web3AuthNetwork: OPENLOGIN_NETWORK_TYPE
  /**
   * @deprecated use web3Auth native Z-Index config through
   * uiConfig.modalZIndex
   */
  loginModalZIndex?: string
}

interface Web3AuthOptions extends Web3AuthNoModalOptions {
  /**
   * web3auth instance provides different adapters for different type of usages. If you are a dapp and want to
   * use external wallets like metamask, then you can use the `DAPP` authMode.
   * If you are a wallet and only want to use you own wallet implementations along with openlogin,
   * then you should use `WALLET` authMode.
   *
   * @defaultValue `DAPP`
   */
  authMode?: 'DAPP' | 'WALLET'
  /**
   * Config for configuring modal ui display properties
   */
  uiConfig?: Omit<UIConfig, 'adapterListener'>
}

interface UIConfig {
  /**
   * App name to display in the UI.
   */
  appName?: string
  /**
   * Logo for your app.
   */
  appLogo?: string
  /**
   * theme for the modal
   *
   * @defaultValue `auto`
   */
  theme?: 'light' | 'dark' | 'auto'
  /**
   * order of how login methods are shown
   *
   * @defaultValue `["google", "facebook", "twitter", "reddit", "discord", "twitch", "apple", "line", "github", "kakao", "linkedin", "weibo", "wechat", "email_passwordless"]`
   */
  loginMethodsOrder?: string[]
  /**
   * language which will be used by web3auth. app will use browser language if not specified. if language is not supported it will use "en"
   * en: english
   * de: german
   * ja: japanese
   * ko: korean
   * zh: mandarin
   * es: spanish
   * fr: french
   * pt: portuguese
   *
   */
  defaultLanguage?: string
  /**
   * Z-index of the modal and iframe
   * @defaultValue 99998
   */
  modalZIndex?: string
  /**
   * Whether to show errors on Web3Auth modal.
   *
   * @defaultValue `true`
   */
  displayErrorsOnModal?: boolean
  /**
   * number of columns to display the Social Login buttons
   *
   * @defaultValue `3`
   */
  loginGridCol?: 2 | 3
  /**
   * decides which button will be displayed as primary button in modal
   * only one button will be primary and other buttons in modal will be secondary
   *
   * @defaultValue `socialLogin`
   */
  primaryButton?: 'externalLogin' | 'socialLogin' | 'emailLogin'
  adapterListener: SafeEventEmitter
  web3AuthNetwork?: OPENLOGIN_NETWORK_TYPE
}
```

## Build Environments

For troubleshooting web3Auth build env troubleshooting please also see the [official Web3Auth troubleshooting docs](https://web3auth.io/docs/troubleshooting/webpack-issues).

### Webpack 4

Node built-ins are automatically bundled in v4 so that portion is handled automatically.

**web3auth** will require a Babel to compile from es6 if not already supported. See config for Babel and Webpack4 as follows

`npm i --save-dev @babel/cli @babel/core @babel/node @babel/plugin-proposal-nullish-coalescing-operator @babel/plugin-proposal-optional-chaining @babel/plugin-syntax-bigint @babel/register`
**AND**
`npm i babel-loader`

**babel.config.js**

```javascript
module.exports = api => {
  api.cache(true)
  const plugins = [
    '@babel/plugin-proposal-optional-chaining',
    '@babel/plugin-proposal-nullish-coalescing-operator',
    '@babel/plugin-syntax-bigint'
  ]
  return { plugins }
}
```

**webpack.config.js**

```javascript
config.module.rules = [
  ...otherModuleRules,
  {
    test: /\.js$/,
    exclude: _ => !/node_modules\/(@web3auth|@ethereumjs)/.test(_),
    loader: 'babel-loader'
  }
]
```

---
_Source: https://npm.io/package/@web3-onboard/web3auth · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
