Web2 Login

Web2 Login

JoyID Web2 login allow you to login to your website using JoyID account. It is a simple and secure way to login to your website without the need to remember password.


npm install @joyid/evm


Before writing business code, you can call the initialization function initConfig on the project entry file. initConfig function take a configuration object as parameter. The configuration object has the following properties:

The joyidAppURL parameter of initConfig() is the JoyID App URL that your app will connect to.


Note that to using Web2 login, you need to import function from @joyid/evm/web2login instead of @joyid/evm.

import React from "react";
import ReactDOM from "react-dom/client";
import { initConfig } from "@joyid/evm/web2login";
import App from "./App";
import "./index.css";
  // background image that will be shown on JoyID app
  // this parameter is followed by the CSS background property
  // ref:
  backgroundImage: 'center center / cover no-repeat url("")',
  // JoyID app url that your app is integrated with
  joyidAppURL: "",
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
    <App />

Connect to JoyID

After initialization, you can call the connect function to connect to JoyID. The connect function returns a Promise, which will be resolved to uid and entropy when the connection is successful.

  • uid: This is a unique identifier specific to each user.
  • entropy: The entropy value remains the same every time the user logs in.

The connect function takes an optional uid parameter. If uid is provided, JoyID will use this specified uid to sign and return the corresponding entropy.

Otherwise, if no uid is provided, JoyID will prompt the user either to create an account or to login with an existing one, then sign and returning the entropy.

import { connect } from '@joyid/evm/web2login'
export default function App() {
  const [response, setResponse] = React.useState();
  const onConnect = async () => {
    try {
      const res = await connect(/* uid is optional */);
    } catch (error) {
  return (
    <div id="app">
      <button className="btn btn-primary" onClick={onConnect}>
        Connect JoyID

Try it out

For a complete demo, you may want to check GitHub ↗ (opens in a new tab) and Live Demo ↗ (opens in a new tab).