@mysten/dapp-kit-react 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/index.d.mts +9 -9
  2. package/docs/actions/connect-wallet.md +68 -0
  3. package/docs/actions/disconnect-wallet.md +37 -0
  4. package/docs/actions/sign-and-execute-transaction.md +95 -0
  5. package/docs/actions/sign-personal-message.md +57 -0
  6. package/docs/actions/sign-transaction.md +64 -0
  7. package/docs/actions/switch-account.md +36 -0
  8. package/docs/actions/switch-network.md +36 -0
  9. package/docs/dapp-kit-instance.md +163 -0
  10. package/docs/getting-started/create-dapp.md +151 -0
  11. package/docs/getting-started/next-js.md +162 -0
  12. package/docs/getting-started/react.md +170 -0
  13. package/docs/getting-started/vue.md +188 -0
  14. package/docs/index.md +70 -0
  15. package/docs/llms-index.md +34 -0
  16. package/docs/react/components/connect-button.md +42 -0
  17. package/docs/react/components/connect-modal.md +51 -0
  18. package/docs/react/components/index.md +13 -0
  19. package/docs/react/dapp-kit-provider.md +86 -0
  20. package/docs/react/hooks/index.md +25 -0
  21. package/docs/react/hooks/use-current-account.md +33 -0
  22. package/docs/react/hooks/use-current-client.md +36 -0
  23. package/docs/react/hooks/use-current-network.md +28 -0
  24. package/docs/react/hooks/use-current-wallet.md +36 -0
  25. package/docs/react/hooks/use-dapp-kit.md +100 -0
  26. package/docs/react/hooks/use-wallet-connection.md +48 -0
  27. package/docs/react/hooks/use-wallets.md +33 -0
  28. package/docs/state.md +168 -0
  29. package/docs/theming.md +196 -0
  30. package/docs/web-components/connect-button.md +87 -0
  31. package/docs/web-components/connect-modal.md +176 -0
  32. package/package.json +4 -2
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import * as _mysten_dapp_kit_core5 from "@mysten/dapp-kit-core";
1
+ import * as _mysten_dapp_kit_core0 from "@mysten/dapp-kit-core";
2
2
  import { DAppKit, DefaultExpectedDppKit, RegisteredDAppKit } from "@mysten/dapp-kit-core";
3
3
  import * as react0 from "react";
4
4
  import { PropsWithChildren } from "react";
@@ -7,7 +7,7 @@ import * as nanostores0 from "nanostores";
7
7
  export * from "@mysten/dapp-kit-core";
8
8
 
9
9
  //#region src/components/DAppKitProvider.d.ts
10
- declare const DAppKitContext: react0.Context<_mysten_dapp_kit_core5.DAppKit<any, _mysten_dapp_kit_core5.ClientWithCoreApi> | null>;
10
+ declare const DAppKitContext: react0.Context<_mysten_dapp_kit_core0.DAppKit<any, _mysten_dapp_kit_core0.ClientWithCoreApi> | null>;
11
11
  type DAppKitProviderProps = PropsWithChildren<{
12
12
  dAppKit: DefaultExpectedDppKit;
13
13
  }>;
@@ -25,7 +25,7 @@ type UseWalletsOptions<TDAppKit extends DAppKit> = {
25
25
  };
26
26
  declare function useWallets<TDAppKit extends DAppKit<any> = RegisteredDAppKit>({
27
27
  dAppKit
28
- }?: UseWalletsOptions<TDAppKit>): _mysten_dapp_kit_core5.UiWallet[];
28
+ }?: UseWalletsOptions<TDAppKit>): _mysten_dapp_kit_core0.UiWallet[];
29
29
  //#endregion
30
30
  //#region src/hooks/useWalletConnection.d.ts
31
31
  type UseWalletConnectionOptions<TDAppKit extends DAppKit<any>> = {
@@ -43,8 +43,8 @@ declare function useWalletConnection<TDAppKit extends DAppKit = RegisteredDAppKi
43
43
  readonly isReconnecting: false;
44
44
  readonly isDisconnected: true;
45
45
  } | {
46
- readonly wallet: _mysten_dapp_kit_core5.UiWallet;
47
- readonly account: _mysten_dapp_kit_core5.UiWalletAccount;
46
+ readonly wallet: _mysten_dapp_kit_core0.UiWallet;
47
+ readonly account: _mysten_dapp_kit_core0.UiWalletAccount;
48
48
  readonly status: "connected";
49
49
  readonly supportedIntents: string[];
50
50
  readonly isConnected: true;
@@ -61,8 +61,8 @@ declare function useWalletConnection<TDAppKit extends DAppKit = RegisteredDAppKi
61
61
  readonly isReconnecting: false;
62
62
  readonly isDisconnected: false;
63
63
  } | {
64
- readonly wallet: _mysten_dapp_kit_core5.UiWallet;
65
- readonly account: _mysten_dapp_kit_core5.UiWalletAccount;
64
+ readonly wallet: _mysten_dapp_kit_core0.UiWallet;
65
+ readonly account: _mysten_dapp_kit_core0.UiWalletAccount;
66
66
  readonly status: "reconnecting";
67
67
  readonly supportedIntents: string[];
68
68
  readonly isConnected: false;
@@ -77,7 +77,7 @@ type UseCurrentAccountOptions<TDAppKit extends DAppKit> = {
77
77
  };
78
78
  declare function useCurrentAccount<TDAppKit extends DAppKit<any> = RegisteredDAppKit>({
79
79
  dAppKit
80
- }?: UseCurrentAccountOptions<TDAppKit>): _mysten_dapp_kit_core5.UiWalletAccount | null;
80
+ }?: UseCurrentAccountOptions<TDAppKit>): _mysten_dapp_kit_core0.UiWalletAccount | null;
81
81
  //#endregion
82
82
  //#region src/hooks/useCurrentWallet.d.ts
83
83
  type UseCurrentWalletOptions<TDAppKit extends DAppKit> = {
@@ -85,7 +85,7 @@ type UseCurrentWalletOptions<TDAppKit extends DAppKit> = {
85
85
  };
86
86
  declare function useCurrentWallet<TDAppKit extends DAppKit<any> = RegisteredDAppKit>({
87
87
  dAppKit
88
- }?: UseCurrentWalletOptions<TDAppKit>): _mysten_dapp_kit_core5.UiWallet | null;
88
+ }?: UseCurrentWalletOptions<TDAppKit>): _mysten_dapp_kit_core0.UiWallet | null;
89
89
  //#endregion
90
90
  //#region src/hooks/useCurrentClient.d.ts
91
91
  type UseCurrentClientOptions<TDAppKit extends DAppKit<any>> = {
@@ -0,0 +1,68 @@
1
+ # Connect Wallet
2
+
3
+ > Programmatically connect to a Sui wallet
4
+
5
+ The dApp Kit SDK provides an action for wallet connection, allowing users to connect, disconnect,
6
+ and switch between wallets and accounts.
7
+
8
+ > The [Connect Button](../web-components/connect-button) Web Component provides a complete wallet
9
+ > connection UI.
10
+
11
+ ## Usage
12
+
13
+ > Auto-connect is enabled by default and will attempt to restore the previous wallet connection on
14
+ > page reload. This provides a seamless user experience but can be
15
+ > [disabled](../dapp-kit-instance#disabling-auto-connect) if needed.
16
+
17
+ The `connectWallet` action prompts a wallet to connect and authorize accounts for your application:
18
+
19
+ ```typescript
20
+ const dAppKit = createDAppKit({
21
+ /* config */
22
+ });
23
+
24
+ // Connect to a specific wallet
25
+ const result = await dAppKit.connectWallet({
26
+ wallet: myWallet, // UiWallet instance
27
+ account: myAccount, // Optional: specific account to select
28
+ });
29
+
30
+ console.log('Connected accounts:', result.accounts);
31
+ ```
32
+
33
+ ## Parameters
34
+
35
+ - **`wallet`** - The `UiWallet` instance to connect to
36
+ - **`account`** (optional) - A specific `UiWalletAccount` to set as the selected account. Defaults
37
+ to the first authorized account
38
+
39
+ ## Return Value
40
+
41
+ Returns a `Promise` that resolves to an object containing:
42
+
43
+ - **`accounts`** - Array of authorized `UiWalletAccount` instances
44
+
45
+ ## Example
46
+
47
+ ```typescript
48
+ const wallets = dAppKit.stores.$wallets.get();
49
+
50
+ const unsubscribe = dAppKit.stores.$connection.subscribe((connection) => {
51
+ if (connection.isConnected) {
52
+ console.log(`Connected account address: ${connection.account.address}`);
53
+ } else {
54
+ console.log({ connection });
55
+ }
56
+ });
57
+
58
+ if (wallets.length > 0) {
59
+ try {
60
+ const { accounts } = await dAppKit.connectWallet({
61
+ wallet: wallets[0],
62
+ });
63
+ console.log('Available accounts:', accounts);
64
+ } catch (error) {
65
+ console.error('Connection failed:', error);
66
+ }
67
+ }
68
+ ```
@@ -0,0 +1,37 @@
1
+ # Disconnect Wallet
2
+
3
+ > Programmatically disconnect from a Sui wallet
4
+
5
+ The `disconnectWallet` action terminates the connection with the currently connected wallet.
6
+
7
+ > The [Connect Button](../web-components/connect-button) Web Component provides a complete wallet
8
+ > connection UI.
9
+
10
+ ## Usage
11
+
12
+ > **Note:** The disconnect action clears the connection state locally and attempts to notify the
13
+ > wallet. Even if the wallet notification fails, the local state is always cleared to ensure a clean
14
+ > disconnection.
15
+ >
16
+ > Note that wallets may or may not implement the `disconnect` feature. Calling `disconnectWallet`
17
+ > doesn't necessarily mean that the wallet accounts will be disconnected from the dApp within the
18
+ > wallet itself - this is determined by each wallet's implementation.
19
+
20
+ ```typescript
21
+ const dAppKit = createDAppKit({
22
+ /* config */
23
+ });
24
+
25
+ await dAppKit.disconnectWallet();
26
+ ```
27
+
28
+ ## Parameters
29
+
30
+ None.
31
+
32
+ ## Return Value
33
+
34
+ Returns a `Promise` that resolves to `void` when the disconnection is complete.
35
+
36
+ > The action may throw `WalletNotConnectedError` if no wallet is connected. However, wallet-specific
37
+ > disconnect failures are logged but don't prevent the local connection state from being cleared.
@@ -0,0 +1,95 @@
1
+ # Sign and Execute Transaction
2
+
3
+ > Sign and execute a transaction using the connected wallet
4
+
5
+ The `signAndExecuteTransaction` action prompts the connected wallet to sign and immediately execute
6
+ a transaction on the Sui network. This is the most common way to execute transactions in your dApp.
7
+
8
+ ## Usage
9
+
10
+ ```typescript
11
+ const dAppKit = createDAppKit({
12
+ /* config */
13
+ });
14
+
15
+ const tx = new Transaction();
16
+ // No need to manually set sender - it's done automatically
17
+ tx.transferObjects([coinWithBalance({ balance: 123 })], '0xrecipient...');
18
+
19
+ const result = await dAppKit.signAndExecuteTransaction({
20
+ transaction: tx,
21
+ });
22
+
23
+ if (result.FailedTransaction) {
24
+ throw new Error(`Transaction failed: ${result.FailedTransaction.status.error?.message}`);
25
+ }
26
+
27
+ console.log('Transaction digest:', result.Transaction.digest);
28
+ ```
29
+
30
+ ## Parameters
31
+
32
+ - **`transaction`** - `Transaction | string` - The transaction to sign and execute. Can be either a
33
+ Transaction instance or base64-encoded bcs bytes for the transaction.
34
+ - **`signal`** (optional) - `AbortSignal` - An abort signal to cancel the transaction request.
35
+
36
+ ## Return Value
37
+
38
+ Returns a `Promise` that resolves to a `TransactionResult` discriminated union:
39
+
40
+ ```typescript
41
+ type TransactionResult =
42
+ | { $kind: 'Transaction'; Transaction: Transaction }
43
+ | { $kind: 'FailedTransaction'; FailedTransaction: Transaction };
44
+ ```
45
+
46
+ The `Transaction` object contains:
47
+
48
+ - **`digest`** - `string` - The transaction digest (unique identifier for the executed transaction)
49
+ - **`signatures`** - `string[]` - The signatures as base64-encoded strings
50
+ - **`epoch`** - `string | null` - The epoch in which the transaction was executed
51
+ - **`status`** - `ExecutionStatus` - The execution status with `success: boolean` and
52
+ `error: string | null`
53
+ - **`effects`** - `TransactionEffects | null` - The parsed transaction effects (may be `null` if
54
+ effects parsing fails for unknown effect versions)
55
+ - **`transaction`** - `TransactionData` - The parsed transaction data
56
+
57
+ ```typescript
58
+ const result = await dAppKit.signAndExecuteTransaction({ transaction });
59
+
60
+ if (result.FailedTransaction) {
61
+ console.error('Transaction failed:', result.FailedTransaction.status.error?.message);
62
+ return;
63
+ }
64
+
65
+ // Access the successful transaction results
66
+ const tx = result.Transaction;
67
+ console.log('Digest:', tx.digest);
68
+ console.log('Signatures:', tx.signatures);
69
+ console.log('Epoch:', tx.epoch);
70
+ ```
71
+
72
+ ## Transaction Building
73
+
74
+ When passing a Transaction instance, the action automatically:
75
+
76
+ 1. Sets the sender address if not already set
77
+ 2. Builds the transaction using the current network's client
78
+ 3. Converts it to the appropriate format for the wallet
79
+ 4. Submits the transaction to the network
80
+
81
+ ## Wallet Compatibility
82
+
83
+ - The action transparently handles both `sui:signAndExecuteTransaction` and
84
+ `sui:signAndExecuteTransactionBlock` wallet-standard features
85
+ - The wallet handles network submission and response
86
+ - Some wallets (Enoki, Enoki Connect, WalletConnect) may use the dApp Kit client and execute
87
+ transactions within the application as an implementation detail
88
+
89
+ ```typescript
90
+ // The action automatically detects and uses the appropriate method
91
+ // No special configuration needed
92
+ const result = await dAppKit.signAndExecuteTransaction({
93
+ transaction: tx,
94
+ });
95
+ ```
@@ -0,0 +1,57 @@
1
+ # Sign Personal Message
2
+
3
+ > Sign an arbitrary message with the connected wallet
4
+
5
+ The `signPersonalMessage` action prompts the connected wallet to sign a personal message. This is
6
+ useful for authentication, proof of ownership, or other scenarios where you need cryptographic proof
7
+ that a user controls a specific account.
8
+
9
+ ## Usage
10
+
11
+ ```typescript
12
+ const dAppKit = createDAppKit({
13
+ /* config */
14
+ });
15
+
16
+ const message = new TextEncoder().encode('Please sign this message');
17
+ const result = await dAppKit.signPersonalMessage({
18
+ message,
19
+ });
20
+
21
+ console.log('Message bytes:', result.bytes);
22
+ console.log('Signature:', result.signature);
23
+ ```
24
+
25
+ ## Parameters
26
+
27
+ - **`message`** - `Uint8Array` - The message to sign as a byte array
28
+
29
+ ## Return Value
30
+
31
+ Returns a `Promise` that resolves to an object containing:
32
+
33
+ - **`bytes`** - `string` - Base64 encoded message bytes
34
+ - **`signature`** - `string` - Base64 encoded signature
35
+
36
+ ## Message Format
37
+
38
+ The message parameter must be a `Uint8Array`. Common patterns for creating byte arrays:
39
+
40
+ ```typescript
41
+ const textMessage = new TextEncoder().encode('Hello, Sui!');
42
+ await dAppKit.signPersonalMessage({ message: textMessage });
43
+
44
+ const jsonMessage = new TextEncoder().encode(
45
+ JSON.stringify({ action: 'sign', timestamp: Date.now() }),
46
+ );
47
+ await dAppKit.signPersonalMessage({ message: jsonMessage });
48
+ ```
49
+
50
+ ## Security Considerations
51
+
52
+ ### Message Content
53
+
54
+ - Always display the message content clearly to users before signing
55
+ - Avoid signing opaque or encoded data that users cannot understand
56
+ - Include human-readable prefixes for different message types
57
+ - Consider adding timestamps to prevent replay attacks
@@ -0,0 +1,64 @@
1
+ # Sign Transaction
2
+
3
+ > Sign a transaction without executing it
4
+
5
+ The `signTransaction` action prompts the connected wallet to sign a transaction without executing
6
+ it. This is useful when you need a signed transaction for later execution or for multi-signature
7
+ scenarios.
8
+
9
+ ## Usage
10
+
11
+ ```typescript
12
+ const dAppKit = createDAppKit({
13
+ /* config */
14
+ });
15
+
16
+ const tx = new Transaction();
17
+ // No need to manually set sender - it's done automatically
18
+ tx.transferObjects([coinWithBalance({ balance: 123 })], '0xrecipient...');
19
+
20
+ // Sign the transaction without executing it
21
+ const { bytes, signature } = await dAppKit.signTransaction({
22
+ transaction: tx,
23
+ });
24
+ ```
25
+
26
+ ## Parameters
27
+
28
+ - **`transaction`** - `Transaction | string` - The transaction to sign. Can be either a Transaction
29
+ instance or base64-encoded bcs bytes for the transaction.
30
+ - **`signal`** (optional) - `AbortSignal` - An abort signal to cancel the signing request.
31
+
32
+ ## Return Value
33
+
34
+ Returns a `Promise` that resolves to an object containing:
35
+
36
+ - **`bytes`** - `string` - The signed transaction as a base64-encoded BCS string
37
+ - **`signature`** - `string` - The signature as a base64-encoded string
38
+
39
+ ```typescript
40
+ const result = await dAppKit.signTransaction({ transaction });
41
+ console.log('Signed transaction bytes:', result.bytes);
42
+ console.log('Signature:', result.signature);
43
+ ```
44
+
45
+ ## Transaction Building
46
+
47
+ When passing a Transaction instance, the action automatically:
48
+
49
+ 1. Sets the sender address if not already set
50
+ 2. Builds the transaction using the current network's client
51
+ 3. Converts it to the appropriate format for the wallet
52
+
53
+ ## Wallet Compatibility
54
+
55
+ - The action transparently handles both `sui:signTransaction` and `sui:signTransactionBlock`
56
+ wallet-standard features
57
+
58
+ ```typescript
59
+ // The action automatically detects and uses the appropriate method
60
+ // No special configuration needed
61
+ const result = await dAppKit.signTransaction({
62
+ transaction: tx,
63
+ });
64
+ ```
@@ -0,0 +1,36 @@
1
+ # Switch Account
2
+
3
+ > Switch the active account in the connected wallet
4
+
5
+ The `switchAccount` action changes the currently selected account to a different account from the
6
+ connected wallet.
7
+
8
+ > **Note:** The "current account" is a dApp Kit concept that tracks which account is active within
9
+ > your application. Changing the active account in the dApp does not affect the wallet itself, and
10
+ > wallets are not notified when the active account changes.
11
+
12
+ > Account switching is integrated into the [Connect Button](../web-components/connect-button) Web
13
+ > Component. When a wallet is connected with multiple accounts, the button provides an account
14
+ > selector.
15
+
16
+ ## Usage
17
+
18
+ ```typescript
19
+ const dAppKit = createDAppKit({
20
+ /* config */
21
+ });
22
+
23
+ // Switch to a different account
24
+ dAppKit.switchAccount({
25
+ account: anotherAccount, // UiWalletAccount from the connected wallet
26
+ });
27
+ ```
28
+
29
+ ## Parameters
30
+
31
+ - **`account`** - `UiWalletAccount` - The account to switch to. Must be an account that belongs to
32
+ the currently connected wallet.
33
+
34
+ ## Return Value
35
+
36
+ Returns `void`. The action completes synchronously and updates the connection state immediately.
@@ -0,0 +1,36 @@
1
+ # Switch Network
2
+
3
+ > Switch the active network for the dApp Kit instance
4
+
5
+ The `switchNetwork` action changes the currently selected network that the dApp Kit client is
6
+ configured to use.
7
+
8
+ > **Note:** Network switching only affects your dApp's client connection. The wallet itself is not
9
+ > affected by this change, and wallets are not notified when the network changes in the dApp.
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ const GRPC_URLS = {
15
+ mainnet: 'https://fullnode.mainnet.sui.io:443',
16
+ testnet: 'https://fullnode.testnet.sui.io:443',
17
+ } as const;
18
+
19
+ const dAppKit = createDAppKit({
20
+ networks: ['mainnet', 'testnet'],
21
+ defaultNetwork: 'mainnet',
22
+ createClient: (network) => new SuiGrpcClient({ network, baseUrl: GRPC_URLS[network] }),
23
+ });
24
+
25
+ // Switch to a different network
26
+ dAppKit.switchNetwork('testnet');
27
+ ```
28
+
29
+ ## Parameters
30
+
31
+ - **`network`** - `TNetworks[number]` - The network to switch to. Must be one of the networks
32
+ configured when creating the dApp Kit instance.
33
+
34
+ ## Return Value
35
+
36
+ Returns `void`. The action completes synchronously and updates the network state immediately.
@@ -0,0 +1,163 @@
1
+ # DApp Kit Instance
2
+
3
+ > Create and configure a DAppKit instance for wallet and client management
4
+
5
+ The `createDAppKit` function is the foundation of your Sui dApp. It creates an instance that manages
6
+ wallet connections, network configuration, and provides access to the Sui client.
7
+
8
+ ## Creating a dApp Kit Instance
9
+
10
+ The core of the dApp Kit SDK is the `createDAppKit` function, which creates an instance that manages
11
+ all dApp functionality:
12
+
13
+ ```typescript
14
+
15
+ const GRPC_URLS = {
16
+ testnet: 'https://fullnode.testnet.sui.io:443',
17
+ };
18
+
19
+ networks: ['testnet'],
20
+ createClient: (network) => new SuiGrpcClient({ network, baseUrl: GRPC_URLS[network] }),
21
+ });
22
+ ```
23
+
24
+ > **Note:** If you use the React bindings, there are two ways to ensure type safety with hooks:
25
+ >
26
+ > 1. [Register the global dAppKit type](./getting-started/react#1-create-a-dapp-kit-instance) once,
27
+ > and all hooks will be properly typed
28
+ > 2. Pass the dAppKit instance explicitly to each hook: `useWalletConnection({ dAppKit })`
29
+
30
+ This instance provides:
31
+
32
+ - Wallet connection management
33
+ - Network switching capabilities
34
+ - Client access for blockchain interactions
35
+ - State stores for reactive updates
36
+
37
+ ## Parameters
38
+
39
+ - **autoConnect** (optional) - Enables automatically connecting to the most recently used wallet
40
+ account (default: `true`)
41
+ - **networks** - A list of networks supported by the application (e.g. `['mainnet', 'testnet']`)
42
+ - **defaultNetwork** (optional) - Initial network to use (default: first network in the array)
43
+ - **createClient** - Creates a new client instance for the given network
44
+ - **enableBurnerWallet** (optional) - Enable development-only burner wallet (default: `false`)
45
+ - **storage** (optional) - Configures how the most recently connected to wallet account is stored
46
+ (default: `localStorage`, set to `null` to disable)
47
+ - **storageKey** (optional) - The key to use to store the most recently connected wallet account
48
+ (default: `'mysten-dapp-kit:selected-wallet-and-address'`)
49
+ - **walletInitializers** (optional) - A list of wallet initializers used for registering additional
50
+ wallet standard wallets.
51
+ - **slushWalletConfig** (optional) - Configuration for Slush wallet (set to `null` to disable the
52
+ wallet)
53
+
54
+ ## Return Value
55
+
56
+ ```ts
57
+ {
58
+ // Actions
59
+ connectWallet: (args: { wallet: UiWallet; account?: UiWalletAccount }) => Promise<{ accounts: UiWalletAccount[]; }>;
60
+ disconnectWallet: () => Promise<void>;
61
+ switchAccount: (args: { account: UiWalletAccount }) => Promise<void>;
62
+ switchNetwork: (network: string) => void;
63
+ signTransaction: (args: { transaction: Transaction | string; signal?: AbortSignal }) => Promise<SignedTransaction>;
64
+ signAndExecuteTransaction: (args: { transaction: Transaction | string; signal?: AbortSignal }) => Promise<TransactionResult>;
65
+ signPersonalMessage: (args: { message: Uint8Array }) => Promise<SignedPersonalMessage>;
66
+
67
+ // Properties
68
+ networks: string[];
69
+ stores: {
70
+ $wallets: DAppKitStores['$compatibleWallets'];
71
+ $connection: DAppKitStores['$connection'];
72
+ $currentNetwork: ReadableAtom<TNetworks[number]>;
73
+ $currentClient: ReadableAtom<Client>;
74
+ };
75
+ getClient: (network?: string) => Client;
76
+ }
77
+ ```
78
+
79
+ Read more about [actions](./actions/connect-wallet) and [stores](./state).
80
+
81
+ ## Basic Usage
82
+
83
+ ```ts
84
+ // dapp-kit.ts
85
+
86
+ const GRPC_URLS = {
87
+ testnet: 'https://fullnode.testnet.sui.io:443',
88
+ };
89
+
90
+ networks: ['testnet'],
91
+ createClient: (network) => new SuiGrpcClient({ network, baseUrl: GRPC_URLS[network] }),
92
+ });
93
+ ```
94
+
95
+ ```ts
96
+ // connect-wallet-and-log.ts
97
+
98
+ wallet,
99
+ account,
100
+ }: {
101
+ wallet: UiWallet;
102
+ account: UiWalletAccount;
103
+ }) {
104
+ const result = await dAppKit.connectWallet({
105
+ wallet,
106
+ account,
107
+ });
108
+ console.log('Connected accounts:', result.accounts);
109
+ }
110
+ ```
111
+
112
+ > If you use the React bindings, see [Getting Started in React](./getting-started/react) and
113
+ > [DAppKitProvider](./react/dapp-kit-provider).
114
+
115
+ ## Development Configuration
116
+
117
+ For development environments, enable the burner wallet:
118
+
119
+ ```typescript
120
+
121
+ networks: ['localnet'],
122
+ defaultNetwork: 'localnet',
123
+ createClient: () => new SuiGrpcClient({ network: 'localnet', baseUrl: 'http://127.0.0.1:9000' }),
124
+ enableBurnerWallet: true, // Dev-only feature
125
+ });
126
+ ```
127
+
128
+ ## Auto-Connect Behavior
129
+
130
+ By default, dApp Kit automatically reconnects to the previously connected wallet.
131
+
132
+ ### Disabling Auto-Connect
133
+
134
+ ```typescript
135
+
136
+ networks: ['mainnet'],
137
+ createClient: () =>
138
+ new SuiGrpcClient({ network: 'mainnet', baseUrl: 'https://fullnode.mainnet.sui.io:443' }),
139
+ autoConnect: false,
140
+ });
141
+ ```
142
+
143
+ ## Custom Wallet Integration
144
+
145
+ Add support for custom wallets using wallet initializers:
146
+
147
+ ```typescript
148
+
149
+ networks: ['mainnet'],
150
+ createClient: () =>
151
+ new SuiGrpcClient({ network: 'mainnet', baseUrl: 'https://fullnode.mainnet.sui.io:443' }),
152
+ walletInitializers: [
153
+ {
154
+ id: 'Custom Wallets',
155
+ initialize() {
156
+ const wallets = [new CustomWallet()];
157
+ const walletsApi = getWallets();
158
+ return { unregister: walletsApi.register(...wallets) };
159
+ },
160
+ },
161
+ ],
162
+ });
163
+ ```