For users who already have wallets, Privy supports signing in with Ethereum (SIWE) or Solana (SIWS). With this flow, users who are already onchain can bring their existing wallet to your app, verify ownership of assets, and take onchain actions.

To have users login to your app with a wallet, use the login method from the usePrivy hook.

Login with wallet is only available using Privy UIs.

login: ({ loginMethods?: ['wallet'], walletChainType?: 'ethereum-only' | 'solana-only' | 'ethereum-and-solana', disableSignup?: boolean }) => void;

Parameters

loginMethods
string[]

The login methods to enable.

walletChainType
'ethereum-only' | 'solana-only' | 'ethereum-and-solana'

The chain type of the wallet to login with.

disableSignup
boolean

Whether to disable signup for the login method.

Returns

void
void

This method does not return anything.

Usage

import { useLogin, usePrivy } from '@privy-io/react-auth';

function LoginButton() {
    const { ready, authenticated } = usePrivy();
    const { login } = useLogin();
    // Disable login when Privy is not ready or the user is already authenticated
    const disableLogin = !ready || (ready && authenticated);

    return (
        <button
            disabled={disableLogin}
            onClick={() => login({
                loginMethods: ['wallet'],
                walletChainType: 'ethereum-and-solana',
                disableSignup: false
            })}
        >
            Log in
        </button>
    );
}

Was this page helpful?