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>
    );
}

Sign in with Ledger on Solana

Currently, Ledger Solana hardware wallets only support transaction signatures, not the message signatures required for Sign-In With Solana (SIWS) authentication. In order to authenticate with a Solana Ledger wallet, you will need to mount the following hook in your application:

import {useSolanaLedgerPlugin} from '@privy-io/react-auth/solana';
...
// Ensure this is mounted throughout the entire sign in flow
useSolanaLedgerPlugin();

Then, when you attempt to login with a Phantom Solana wallet, you will be prompted to indicate whether you are signing with a Ledger wallet, which will initiate a separate SIWS flow wherein which a no-op transaction will be signed and used for verification.