MCPcopy Index your code
hub / github.com/Web3Auth/web3auth-web

github.com/Web3Auth/web3auth-web @v11.3.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v11.3.0 ↗ · + Follow
1,340 symbols 3,551 edges 400 files 40 documented · 3%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Web3Auth

lerna code style: prettier npm

Web3Auth is where passwordless auth meets non-custodial key infrastructure for Web3 apps and wallets. By aggregating OAuth (Google, Twitter, Discord) logins, different wallets and innovative Multi Party Computation (MPC) - Web3Auth provides a seamless login experience to every user on your application.

📖 Documentation

Checkout the official Web3Auth Documentation and SDK Reference to get started!

⚠️ Deprecations

  • Farcaster login is no longer supported. The farcaster value of AUTH_CONNECTION has been deprecated and is no longer offered by either @web3auth/modal or @web3auth/no-modal. The modal will reject any project configuration that enables loginMethods.farcaster, and noModal.connectTo(WALLET_CONNECTORS.AUTH, { authConnection: "farcaster" }) will throw a deprecation error. If you previously relied on Farcaster login, please migrate to one of the other supported AUTH_CONNECTION values.

💡 Features

  • Plug and Play, OAuth based Web3 Authentication Service
  • Fully decentralized, non-custodial key infrastructure
  • End to end Whitelabelable solution
  • Threshold Cryptography based Key Reconstruction
  • Multi Factor Authentication Setup & Recovery (Includes password, backup phrase, device factor editing/deletion etc)
  • Support for Email and Mobile Passwordless Login
  • Support for connecting to multiple wallets
  • DApp Active Session Management

...and a lot more

🎯 Web3Auth Modal SDK

Web3Auth Plug and Play Modal SDK @web3auth/modal provides a simple and easy to use SDK that will give you a simple modular way of implementing Web3Auth directly within your application. You can use the pre-configured Web3Auth Modal UI and whitelabel it according to your needs.

⚡ Quick Start

Installation

npm install --save @web3auth/modal

Prerequisites

Before you start, make sure you have registered on the Web3Auth Dashboard and have set up your project. Use the Client ID of the project to start your integration.

React Integration

Web3Auth provides React Hooks for seamless integration with React applications.

1. Create Configuration

// web3authContext.tsx
import { type Web3AuthContextConfig } from "@web3auth/modal/react";
import { WEB3AUTH_NETWORK, type Web3AuthOptions } from "@web3auth/modal";

const web3AuthOptions: Web3AuthOptions = {
  clientId: "YOUR_CLIENT_ID", // Get your Client ID from Web3Auth Dashboard
  web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET, // or WEB3AUTH_NETWORK.SAPPHIRE_DEVNET
};

const web3AuthContextConfig: Web3AuthContextConfig = {
  web3AuthOptions,
};

export default web3AuthContextConfig;

2. Setup Provider

// main.tsx or index.tsx
import ReactDOM from "react-dom/client";
import { Web3AuthProvider } from "@web3auth/modal/react";
import web3AuthContextConfig from "./web3authContext";
import App from "./App";

ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
  <Web3AuthProvider config={web3AuthContextConfig}>
    <App />
  </Web3AuthProvider>
);

3. Use Web3Auth Hooks

// App.tsx
import { useWeb3AuthConnect } from "@web3auth/modal/react";

function ConnectButton() {
  const { connect, loading, isConnected, error } = useWeb3AuthConnect();

  return (
    <button onClick={() => connect()} disabled={loading || isConnected}>
      {loading ? "Connecting..." : isConnected ? "Connected" : "Connect"}
    </button>
    {error && 

{error.message}

}
  );
}

Vue Integration

Web3Auth provides Vue Composables for seamless integration with Vue applications.

1. Create Configuration

// web3authContext.ts
import { type Web3AuthContextConfig } from "@web3auth/modal/vue";
import { WEB3AUTH_NETWORK, type Web3AuthOptions } from "@web3auth/modal";

const web3AuthOptions: Web3AuthOptions = {
  clientId: "YOUR_CLIENT_ID", // Get your Client ID from Web3Auth Dashboard
  web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET, // or WEB3AUTH_NETWORK.SAPPHIRE_DEVNET
};

const web3AuthContextConfig: Web3AuthContextConfig = {
  web3AuthOptions,
};

export default web3AuthContextConfig;

2. Setup Provider


<script setup lang="ts">
import Home from "./Home.vue";
import { Web3AuthProvider } from "@web3auth/modal/vue";
import web3AuthContextConfig from "./web3authContext";
</script>

<template>
  <Web3AuthProvider :config="web3AuthContextConfig">
    <Home />
  </Web3AuthProvider>
</template>

3. Use Web3Auth Composables


<script setup lang="ts">
  import { useWeb3AuthConnect } from "@web3auth/modal/vue";

  const { connect, loading, isConnected, error } = useWeb3AuthConnect();
</script>

<template>
  <button @click="connect" :disabled="loading || isConnected">
    <span v-if="loading">Connecting...</span>
    <span v-else-if="isConnected">Connected</span>
    <span v-else>Connect</span>
  </button>


{{ error.message }}


</template>

JavaScript Integration

For vanilla JavaScript or other frameworks, use the standard Web3Auth Modal SDK.

1. Initialize Web3Auth

import { Web3Auth, WEB3AUTH_NETWORK } from "@web3auth/modal";

const web3auth = new Web3Auth({
  clientId: "YOUR_CLIENT_ID", // Get your Client ID from Web3Auth Dashboard
  web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET, // or WEB3AUTH_NETWORK.SAPPHIRE_DEVNET
});

// Initialize the SDK
await web3auth.init();

2. Login User

// Login
await web3auth.connect();

// Get user info
const user = await web3auth.getUserInfo();

// Logout
await web3auth.logout();

🔧 Advanced Configuration

The Web3Auth Modal SDK offers a rich set of advanced configuration options:

  • Smart Accounts: Configure account abstraction parameters
  • Custom Authentication: Define authentication methods
  • Whitelabeling & UI Customization: Personalize the modal's appearance
  • Multi-Factor Authentication (MFA): Set up and manage MFA
  • Wallet Services: Integrate additional wallet services

⏪ Requirements

  • All packages require a peer dependency of @babel/runtime
  • Node 18+

🧳 Bundling

This module is distributed in 4 formats

  • esm build dist/package.esm.js in es6 format
  • commonjs build dist/package.cjs.js in es5 format
  • umd build dist/package.umd.min.js in es5 format without polyfilling corejs minified

By default, the appropriate format is used for your specified usecase You can use a different format (if you know what you're doing) by referencing the correct file

The cjs build is not polyfilled with core-js. It is upto the user to polyfill based on the browserlist they target

Directly in Browser

CDN's serve the non-core-js polyfilled version by default. You can use a different

Please replace package and version with the appropriate package name

jsdeliver

<script src="https://cdn.jsdelivr.net/npm/@web3auth/PACKAGE@VERSION"></script>

unpkg

<script src="https://unpkg.com/@web3auth/PACKAGE@VERSION"></script>

🩹 Examples

Check out the examples for your preferred blockchain and platform on our examples page.

🌐 Demo

Checkout the Web3Auth Demo to see how Web3Auth can be used in your application.

For more detailed examples, visit our Web3Auth Examples repository. This repository contains a comprehensive collection of sample projects to help you get started with your Web3Auth integration.

💬 Troubleshooting and Support

  • Have a look at our Community Portal to see if anyone has any questions or issues you might be having. Feel free to create new topics and we'll help you out as soon as possible.
  • Checkout our Troubleshooting Documentation Page to know the common issues and solutions.
  • For Priority Support, please have a look at our Pricing Page for the plan that suits your needs.

Extension points exported contracts — how you extend this code

IUseEnableMFA (Interface)
(no doc) [10 implementers]
packages/no-modal/src/react/hooks/useEnableMFA.ts
IWeb3AuthModal (Interface)
(no doc) [12 implementers]
packages/modal/src/interface.ts
FetchResultProps (Interface)
(no doc)
demo/wagmi-react-app/src/components/X402.tsx
IUseWeb3AuthDisconnect (Interface)
(no doc) [10 implementers]
packages/no-modal/src/react/hooks/useWeb3AuthDisconnect.ts
ModalConfig (Interface)
(no doc)
packages/modal/src/interface.ts
IUseManageMFA (Interface)
(no doc) [10 implementers]
packages/no-modal/src/react/hooks/useManageMFA.ts
ConnectorsModalConfig (Interface)
(no doc)
packages/modal/src/interface.ts
IUseEnableMFA (Interface)
(no doc) [10 implementers]
packages/no-modal/src/vue/composables/useEnableMFA.ts

Core symbols most depended-on inside this repo

invalidParams
called by 74
packages/no-modal/src/base/errors/index.ts
connectionError
called by 58
packages/no-modal/src/base/errors/index.ts
notReady
called by 56
packages/no-modal/src/base/errors/index.ts
track
called by 54
packages/no-modal/src/base/analytics.ts
setState
called by 53
packages/no-modal/src/noModal.ts
notConnectedError
called by 44
packages/no-modal/src/base/errors/index.ts
uiConsole
called by 41
demo/react-app-no-modal/src/App.tsx
cn
called by 40
packages/modal/src/ui/utils.ts

Shape

Function 573
Method 533
Interface 152
Class 76
Enum 6

Languages

TypeScript100%

Modules by API surface

packages/no-modal/src/noModal.ts103 symbols
packages/no-modal/src/base/errors/index.ts52 symbols
packages/no-modal/src/connectors/auth-connector/authConnector.ts48 symbols
packages/modal/src/modalManager.ts45 symbols
packages/no-modal/src/base/connector/interfaces.ts27 symbols
packages/no-modal/test/helpers.ts25 symbols
packages/no-modal/src/connectors/wallet-connect-v2-connector/walletConnectV2Connector.ts23 symbols
packages/no-modal/src/connectors/metamask-connector/metamaskConnector.ts21 symbols
packages/no-modal/test/noModal.test.ts20 symbols
packages/no-modal/src/base/core/IWeb3Auth.ts20 symbols
packages/no-modal/src/providers/base-provider/baseProvider.ts19 symbols
packages/no-modal/src/providers/account-abstraction-provider/providers/AccountAbstractionProvider.ts18 symbols

For agents

$ claude mcp add web3auth-web \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page