llms.txt
@mysten/sui v2.0 and a new dApp Kit are here! Check out the migration guide
Mysten Labs SDKs
dApp Kit (Legacy)Wallet components

ConnectModal

Legacy React modal component that guides users through connecting their wallet.

The ConnectModal component opens a modal that guides the user through connecting their wallet to the app.

Controlled example

import { ConnectModal, useCurrentAccount } from '@mysten/dapp-kit';
import { useState } from 'react';

export function YourApp() {
	const currentAccount = useCurrentAccount();
	const [open, setOpen] = useState(false);

	return (
		<ConnectModal
			trigger={
				<button disabled={!!currentAccount}> {currentAccount ? 'Connected' : 'Connect'}</button>
			}
			open={open}
			onOpenChange={(isOpen) => setOpen(isOpen)}
		/>
	);
}

Click Connect to connect your wallet and see the previous code in action:

Loading...

Uncontrolled example

import { ConnectModal, useCurrentAccount } from '@mysten/dapp-kit';

export function YourApp() {
	const currentAccount = useCurrentAccount();

	return (
		<ConnectModal
			trigger={
				<button disabled={!!currentAccount}> {currentAccount ? 'Connected' : 'Connect'}</button>
			}
		/>
	);
}

Click Connect to connect your wallet and see the previous code in action:

Loading...

Controlled props

  • open: The controlled open state of the dialog.
  • onOpenChange: Event handler called when the open state of the dialog changes.
  • trigger: The trigger button that opens the dialog.
  • walletFilter: A filter function that receives a wallet instance, and returns a boolean indicating whether the wallet should be displayed in the wallet list. By default, all wallets are displayed.

Uncontrolled props

  • defaultOpen: The open state of the dialog when it is initially rendered. Use when you do not need to control its open state.
  • trigger: The trigger button that opens the dialog.
  • walletFilter: A filter function that receives a wallet instance, and returns a boolean indicating whether the wallet should be displayed in the wallet list. By default, all wallets are displayed.

On this page