0.1.1 • Published 7 months ago
@djuno/web3auth-hook v0.1.1
@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-hookoryarn add @djuno/web3auth-hookto install.
Quickstart
- 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:
AppComponent: Shows how to set up theWeb3authProviderat the root of your React app, passing theaccessKeyfor configuration.NetworksComponent: Demonstrates how to use theuseWeb3Authhook to fetch available networks and display them in a list.