Mesh LogoMesh
ResourcesSolutions

Wallet Integration

Add Cardano wallet connectivity in minutes with Mesh SDK's unified API for all CIP-30 wallets.

Mesh provides the fastest Cardano wallet integration. Add multi-wallet support with pre-built React components or build custom UIs with the unified API.

Quick start

npm install @meshsdk/core @meshsdk/react

1. Add MeshProvider

import { MeshProvider } from "@meshsdk/react";

function App() {
  return (
    <MeshProvider>
      <YourApp />
    </MeshProvider>
  );
}

2. Add wallet connection

import { CardanoWallet } from "@meshsdk/react";

function Header() {
  return (
    <header>
      <Logo />
      <CardanoWallet />
    </header>
  );
}

3. Access wallet state

import { useWallet } from "@meshsdk/react";

function Dashboard() {
  const { connected, wallet } = useWallet();

  if (!connected) return <p>Please connect your wallet</p>;

  return <WalletDashboard wallet={wallet} />;
}

Features

FeatureDescription
Universal supportAll CIP-30 wallets (Eternl, Lace, Yoroi, Typhon...)
Pre-built componentsCardanoWallet handles everything
React hooksReactive state management
Automatic detectionIdentifies all installed wallets
Normalized APIConsistent methods across wallets
TypeScriptFull type definitions

API options

CardanoWallet component

Complete wallet UI in one component:

<CardanoWallet
  label="Connect Wallet"
  onConnected={() => console.log("Connected!")}
  isDark={true}
/>

useWallet hook

Access wallet state anywhere:

const {
  connected,      // boolean
  wallet,         // BrowserWallet instance
  connect,        // function to connect
  disconnect,     // function to disconnect
  connecting,     // boolean
  name,           // wallet name
} = useWallet();

MeshCardanoBrowserWallet class

For full control:

import { MeshCardanoBrowserWallet } from "@meshsdk/wallet";

// Detect installed wallets
const wallets = MeshCardanoBrowserWallet.getInstalledWallets();

// Connect to specific wallet
const wallet = await MeshCardanoBrowserWallet.enable("eternl");

// Unified API (Mesh format)
const utxos = await wallet.getUtxosMesh();
const address = await wallet.getChangeAddressBech32();
const balance = await wallet.getBalanceMesh();

Common patterns

Persist wallet connection

import { useEffect } from "react";
import { useWallet } from "@meshsdk/react";

function WalletManager() {
  const { connected, connect, wallet } = useWallet();

  useEffect(() => {
    const saved = localStorage.getItem("preferredWallet");
    if (saved && !connected) connect(saved);
  }, []);

  useEffect(() => {
    if (connected && wallet) {
      localStorage.setItem("preferredWallet", wallet.walletId);
    }
  }, [connected]);

  return <CardanoWallet />;
}

Validate network

const networkId = await wallet.getNetworkId();
if (networkId !== 1) {
  throw new Error("Please switch to Mainnet");
}

Handle errors

try {
  await connect(walletId);
} catch (error) {
  if (error.message.includes("User")) {
    showToast("Connection cancelled");
  } else if (error.message.includes("popup")) {
    showToast("Please allow popups");
  } else {
    showToast("Failed to connect");
  }
}

Custom wallet UI

import { MeshCardanoBrowserWallet } from "@meshsdk/wallet";
import { useWallet } from "@meshsdk/react";

function CustomWalletButton() {
  const { connect, connected, disconnect, name } = useWallet();
  const wallets = MeshCardanoBrowserWallet.getInstalledWallets();

  if (connected) {
    return (
      <button onClick={disconnect}>
        Disconnect {name}
      </button>
    );
  }

  return (
    <div className="wallet-options">
      {wallets.map(w => (
        <button key={w.id} onClick={() => connect(w.id)}>
          <img src={w.icon} alt={w.name} />
          {w.name}
        </button>
      ))}
    </div>
  );
}

Why choose Mesh for wallets

BenefitDetails
One interface for allNo wallet-specific code
Production testedPowers major Cardano dApps
Actively maintainedUpdates for new wallets and changes
TypeScript supportFull type definitions

On this page