Cannot login user with Web3AuthNoModal - Vue&Vite

What I am trying to do is create my own UI (I don’t need a modal, I just need the form). I tried the examples in the documentation (integration builder) as well as the one here:

Below you can find the basic code for the component.

<template>
  <div id="app">
    <button class="card" style="cursor: pointer" @click="login">Login</button>
  </div>
</template>

<script lang="ts" setup>
import { onMounted } from 'vue';
import { Web3AuthNoModal } from '@web3auth/no-modal';
import { CHAIN_NAMESPACES } from '@web3auth/base';

const clientId = import.meta.env.VITE_CLIENT_ID;

const web3auth = new Web3AuthNoModal({
  clientId, // get it from Web3Auth Dashboard
  web3AuthNetwork: 'testnet',
  chainConfig: {
    chainNamespace: CHAIN_NAMESPACES.EIP155,
    chainId: '0xA869',
    rpcTarget: 'https://api.avax-test.network/ext/bc/C/rpc',
  },
});

onMounted(async () => {
  await web3auth.init();
});

const login = async () => {
  await web3auth.connectTo('openlogin', {
    loginProvider: 'google',
  });
};
</script>

While using @web3auth/nomodal sdk you need to add/configure each adapter that you want to use with your application. Your code seems to missing adding/configuring adapters. Please Refer to this doc for more info: Initialize Plug n Play Core | Documentation

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.