Skip to main content
  • React
Once a user has connected their wallet to your app, and the wallet is available in either of the useWallets arrays, you can also prompt them to login with that wallet or link that wallet to their existing account, instead of prompting the entire login or linkWallet flow.To do so, find the ConnectedWallet or ConnectedStandardSolanaWallet object from Privy, and call the object’s loginOrLink method for EVM wallets and use the useLoginWithSiws or useLinkWithSiws hooks for the Solana wallets:
  • EVM
  • Solana
import {useWallets} from '@privy-io/react-auth';
...
const {wallets} = useWallets();
...
wallets[0].loginOrLink();
When called, loginOrLink will directly request a SIWE signature from the user’s connected wallet to authenticate the wallet.If the user was not authenticated when the method was called, the user will become authenticated after signing the message.If the user was already authenticated when the method was called, the user will remain authenticated after signing the message, and the connected wallet will become one of the user’s linkedAccounts in their user object.You might use the methods above to “split up” the connect and sign steps of external wallet login, like so:
  • EVM
  • Solana
import {useConnectWallet, useWallets} from '@privy-io/react-auth';

export default function WalletButton() {
const {connectWallet} = useConnectWallet();
const {wallets} = useWallets();

// Prompt user to connect a wallet with Privy modal
return (
    {/* Button to connect wallet */}
    <button
        onClick={connectWallet}>
        Connect wallet
    </button>
    {/* Button to login with or link the most recently connected wallet */}
    <button
        disabled={!wallets[0]}
        onClick={() => { wallets[0].loginOrLink() }}>
        Login with wallet
    </button>
);
}
I