0.1.1 • Published 7 months ago

@djuno/web3auth-hook v0.1.1

Weekly downloads
-
License
-
Repository
-
Last release
7 months ago

@djuno/web3auth-hook

A React package from Djuno that provides an easy way to integrate Djuno's web3auth service into React applications. This package serves as a wrapper around Djuno's web3auth-sdk, offering hooks for authentication and profile management.

This package supports both JavaScript and TypeScript, and is designed to work seamlessly in React projects.

Getting Started

Installation

  • Requires Node.js v16 or higher
  • Run npm install @djuno/web3auth-hook or yarn add @djuno/web3auth-hook to install.

Quickstart

  1. Setting up the Web3authProvider

You need to wrap your app in a Web3authProvider to provide access to the Web3Auth context:

import { useWeb3Auth } from '@djuno/web3auth-hook';
import { useEffect } from 'react';

const Networks = () => {
  const { getNetworks } = useWeb3Auth();

  useEffect(() => {
    getNetworks();
  }, []);

  return <div>Welcome to Web3authHook!</div>;
};
export default Networks;
import { Web3authProvider } from '@djuno/web3auth-hook';
import Networks from './components/Networks';

function App() {
  const accessKey = 'your-access-key'; // Replace with your Web3Auth key

  return (
    <Web3authProvider clientConfigs={{ accessKey }}>
      <Networks />
    </Web3authProvider>
  );
}

export default App;

Explanation of the Example Code:

  1. App Component: Shows how to set up the Web3authProvider at the root of your React app, passing the accessKey for configuration.
  2. Networks Component: Demonstrates how to use the useWeb3Auth hook to fetch available networks and display them in a list.
0.1.1

7 months ago

0.0.4

9 months ago

0.0.3

9 months ago

0.0.2

10 months ago