Skip to main content

Sign in with World ID with Web3Auth

note

Sign in with World ID can be performed in various ways, depending on the use case. We have demonstrated this with Auth0, but this can be done by hosting your own server with Auth.js or using NextAuth implementation. Check out the Sign in with World ID documentation.

Add WorldCoin to your Auth0 Application

  1. In your Auth0 Dashboard, Add the WorldCoin Social Connection to your Auth0 application.

Create a WorldCoin Verifier

  • Go to the Web3Auth dashboard and select your project. Click on the Custom Authentication tab, then click on the Create Verifier button to create a new verifier.

    Custom Authentication Dashboard

  1. Give a unique name to your verifier in the Verifier Identifier field. e.g., web3auth-worldcoin-verifier.

  2. From the list of Login Providers, select Social Login Providers and from the Select Login Provider dropdown, select Auth0. WorldCoin - Login Providers list on Web3Auth Dashboard

  3. Select Other as the Authentication Type based on the dropdown. WorldCoin - Auth0 Authentication Type list on Web3Auth Dashboard

  4. Enter the Auth0 Client ID and Auth0 Domain from your Auth0 application. See how to create a new Auth0 application here.

    WorldCoin - Domain and Client ID from Auth0 Dashboard

  5. Click on the Create button to create the WorldCoin Custom Authentication via Auth0 verifier.

    note

    It typically takes 5-10 minutes for the verifier to go live. Once deployed & live, you'll receive an email and the dashboard will display the 'Live' status for the verifier.

Example

import { AuthAdapter } from "@web3auth/auth-adapter";

// Create AuthAdapter instance once you have created Web3AuthNoModal instance
const authAdapter = new AuthAdapter({
adapterSettings: {
loginConfig: {
jwt: {
verifier: "w3a-worldcoin-demo", // Pass the Verifier name here
typeOfLogin: "jwt", // Pass on the login provider of the verifier you've created
clientId: "7u5jfJ3bakrfLBJYhyTquohpOth0Tmt7", // Pass on the Auth0 `Client ID` here
},
},
},
});

web3AuthNoModalInstance.configureAdapter(authAdapter);

// Initialize
await web3AuthNoModalInstance.init();

// Login with WorldCoin
await web3AuthNoModalInstance.connectTo(WALLET_ADAPTERS.AUTH, {
loginProvider: "jwt",
extraLoginOptions: {
domain: "https://web3auth.jp.auth0.com", // Pass on the Auth0 `Domain` here
verifierIdField: "sub", // Pass on the field name of the `sub` field in the JWT
connection: "worldcoin", // Use this to skip Auth0 Modal for WorldCoin's World ID
},
});