Skip to Content
PasskeysRecipesDetecting Wallets

Detecting Wallets

Use the detectWallets utility to check for available wallet providers in the browser environment.

Usage

import { detectWallets } from '@passkeys/core';
 
// Call the function to get a list of available wallets
const wallets = detectWallets();
 
console.log('Available wallets:', wallets);
/*
  Example output:
  [
    { id: 'passkeys', name: 'Passkeys', providers: ['ethereum', 'solana', 'bitcoin'] },
    { id: 'metamask', name: 'MetaMask', providers: ['ethereum'] },
    { id: 'phantom', name: 'Phantom', providers: ['solana'] }
  ]
*/

Advanced Usage with Type Checking

You can use type checking to handle specific wallet providers:

import { detectWallets } from '@passkeys/core';
 
const wallets = detectWallets();
 
// Check if MetaMask is available
const hasMetaMask = wallets.some((wallet) => wallet.id === 'metamask');
 
// Check if any wallet supporting Solana is available
const hasSolanaWallet = wallets.some((wallet) => wallet.providers.includes('solana'));
 
// Check if Passkeys wallet is available
const hasPasskeys = wallets.some((wallet) => wallet.id === 'passkeys');
 
// Get all wallets that support Ethereum
const ethereumWallets = wallets.filter((wallet) => wallet.providers.includes('ethereum'));

Return Type

interface WalletInfo {
  id: string; // Unique identifier for the wallet
  name: string; // Display name of the wallet
  providers: string[]; // Supported blockchain providers (e.g., 'ethereum', 'solana', 'bitcoin')
}

The function returns an array of WalletInfo objects representing the detected wallets.

Last updated on

Start building

XO

Request Demo

Schedule a call with our team

Select a product
Arrow right