Use Login with Viem Hook
A hook to execute login with the Lens React SDK using the Viem library for wallet interaction.
This hook executes useLogin from the Lens React SDK using a WalletClient from Viem to sign the authentication message. It is designed to fetch the currently authenticated Lens Account. It returns the authenticated user data, loading state, and any errors encountered during the fetch process.
Installation
Usage
This example uses the wagmi library to manage the WalletClient, but this is not strictly required.
import { useLensLoginWithViem } from "@/hooks/use-lens-login-with-viem";
import { useSessionClient } from "@lens-protocol/react";
import { useWalletClient } from "wagmi";
const { data: walletClient } = useWalletClient();
const { data: sessionClient } = useSessionClient();
const { execute: login } = useLensLoginWithViem({ sessionClient });
const user = await login(walletClient, account);}