@mysten/dapp-kit-react 2.0.1 → 2.0.3
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.
- package/dist/index.d.mts +9 -9
- package/dist/index.d.mts.map +1 -1
- package/dist/ui.d.mts.map +1 -1
- package/docs/actions/connect-wallet.md +6 -5
- package/docs/actions/disconnect-wallet.md +12 -10
- package/docs/actions/sign-and-execute-transaction.md +16 -15
- package/docs/actions/sign-personal-message.md +10 -9
- package/docs/actions/sign-transaction.md +9 -8
- package/docs/actions/switch-account.md +8 -7
- package/docs/actions/switch-network.md +7 -6
- package/docs/dapp-kit-instance.md +22 -22
- package/docs/getting-started/create-dapp.md +13 -13
- package/docs/getting-started/next-js.md +14 -13
- package/docs/getting-started/react.md +29 -27
- package/docs/getting-started/vue.md +20 -15
- package/docs/index.md +10 -10
- package/docs/llms-index.md +30 -31
- package/docs/react/components/connect-button.md +4 -4
- package/docs/react/components/connect-modal.md +4 -4
- package/docs/react/components/index.md +3 -3
- package/docs/react/dapp-kit-provider.md +7 -7
- package/docs/react/hooks/index.md +5 -4
- package/docs/react/hooks/use-current-account.md +4 -4
- package/docs/react/hooks/use-current-client.md +7 -7
- package/docs/react/hooks/use-current-network.md +4 -4
- package/docs/react/hooks/use-current-wallet.md +4 -4
- package/docs/react/hooks/use-dapp-kit.md +6 -6
- package/docs/react/hooks/use-wallet-connection.md +4 -4
- package/docs/react/hooks/use-wallets.md +4 -4
- package/docs/state.md +18 -17
- package/docs/theming.md +32 -32
- package/docs/web-components/connect-button.md +13 -11
- package/docs/web-components/connect-modal.md +18 -17
- package/package.json +3 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Next.js
|
|
2
2
|
|
|
3
|
-
> Set up dApp Kit in a Next.js application
|
|
3
|
+
> Set up dApp Kit in a Next.js application.
|
|
4
4
|
|
|
5
5
|
This guide covers integrating dApp Kit into Next.js applications, including handling server-side
|
|
6
6
|
rendering (SSR).
|
|
@@ -13,7 +13,7 @@ npm i @mysten/dapp-kit-react @mysten/sui
|
|
|
13
13
|
|
|
14
14
|
## Setup
|
|
15
15
|
|
|
16
|
-
### 1
|
|
16
|
+
### Step 1: Create a dApp Kit instance
|
|
17
17
|
|
|
18
18
|
```ts
|
|
19
19
|
// app/dapp-kit.ts
|
|
@@ -34,7 +34,7 @@ declare module '@mysten/dapp-kit-react' {
|
|
|
34
34
|
}
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
### 2
|
|
37
|
+
### Step 2: Create a client-only wrapper
|
|
38
38
|
|
|
39
39
|
Wallet detection only works in the browser, so dApp Kit components must be client-side rendered:
|
|
40
40
|
|
|
@@ -47,7 +47,7 @@ Wallet detection only works in the browser, so dApp Kit components must be clien
|
|
|
47
47
|
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
### 3
|
|
50
|
+
### Step 3: Use dynamic import in pages
|
|
51
51
|
|
|
52
52
|
Use Next.js dynamic imports with `ssr: false` to prevent server-side rendering:
|
|
53
53
|
|
|
@@ -75,7 +75,7 @@ const ConnectButton = dynamic(
|
|
|
75
75
|
}
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
## Alternative:
|
|
78
|
+
## Alternative: single client component
|
|
79
79
|
|
|
80
80
|
For simpler apps, create a single client component:
|
|
81
81
|
|
|
@@ -137,26 +137,27 @@ const WalletApp = dynamic(() => import('./WalletApp'), {
|
|
|
137
137
|
}
|
|
138
138
|
```
|
|
139
139
|
|
|
140
|
-
## Key
|
|
140
|
+
## Key considerations
|
|
141
141
|
|
|
142
142
|
### Why SSR: false?
|
|
143
143
|
|
|
144
|
-
Wallets are detected
|
|
145
|
-
cannot happen on the server, so components that interact with wallets must be client-side
|
|
144
|
+
Wallets are detected through the browser's `window` object and the Wallet Standard API. This
|
|
145
|
+
detection cannot happen on the server, so components that interact with wallets must be client-side
|
|
146
|
+
only.
|
|
146
147
|
|
|
147
|
-
### Hydration
|
|
148
|
+
### Hydration errors
|
|
148
149
|
|
|
149
150
|
If you see hydration errors, ensure all dApp Kit components are wrapped with `ssr: false` dynamic
|
|
150
151
|
imports or are inside a `'use client'` component that's dynamically imported.
|
|
151
152
|
|
|
152
|
-
## Example
|
|
153
|
+
## Example application
|
|
153
154
|
|
|
154
155
|
See the complete
|
|
155
|
-
[Next.js example](https://github.com/MystenLabs/ts-sdks/tree/main/packages/dapp-kit
|
|
156
|
+
[Next.js example](https://github.com/MystenLabs/ts-sdks/tree/main/packages/dapp-kit/examples/next-js/simple)
|
|
156
157
|
on GitHub.
|
|
157
158
|
|
|
158
|
-
## Next
|
|
159
|
+
## Next steps
|
|
159
160
|
|
|
160
161
|
- [React Hooks](/dapp-kit/react/hooks) - All available hooks
|
|
161
162
|
- [React Components](/dapp-kit/react/components) - UI components
|
|
162
|
-
- [Theming](/dapp-kit/theming) - Customize appearance
|
|
163
|
+
- [Theming](/dapp-kit/theming) - Customize appearance
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# React
|
|
2
2
|
|
|
3
|
-
> Set up dApp Kit in a React application
|
|
3
|
+
> Set up dApp Kit in a React application.
|
|
4
4
|
|
|
5
5
|
This guide walks you through integrating dApp Kit into a React application.
|
|
6
6
|
|
|
7
|
-
## Quick
|
|
7
|
+
## Quick start with create-dapp
|
|
8
8
|
|
|
9
9
|
The fastest way to get started is using our CLI tool:
|
|
10
10
|
|
|
@@ -28,7 +28,7 @@ See the [create-dapp guide](/dapp-kit/getting-started/create-dapp) for more deta
|
|
|
28
28
|
|
|
29
29
|
---
|
|
30
30
|
|
|
31
|
-
## Manual
|
|
31
|
+
## Manual installation
|
|
32
32
|
|
|
33
33
|
```sh npm2yarn
|
|
34
34
|
npm i @mysten/dapp-kit-react @mysten/sui
|
|
@@ -36,7 +36,7 @@ npm i @mysten/dapp-kit-react @mysten/sui
|
|
|
36
36
|
|
|
37
37
|
## Setup
|
|
38
38
|
|
|
39
|
-
### 1
|
|
39
|
+
### Step 1: Create a dApp Kit instance
|
|
40
40
|
|
|
41
41
|
Create a file to configure your dApp Kit instance:
|
|
42
42
|
|
|
@@ -59,7 +59,7 @@ declare module '@mysten/dapp-kit-react' {
|
|
|
59
59
|
}
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
### 2
|
|
62
|
+
### Step 2: Add the provider
|
|
63
63
|
|
|
64
64
|
Wrap your application with `DAppKitProvider`:
|
|
65
65
|
|
|
@@ -78,11 +78,12 @@ Wrap your application with `DAppKitProvider`:
|
|
|
78
78
|
}
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
### 3
|
|
81
|
+
### Step 3: Display connection status
|
|
82
82
|
|
|
83
83
|
Use hooks to access wallet state:
|
|
84
84
|
|
|
85
85
|
```tsx
|
|
86
|
+
|
|
86
87
|
function WalletStatus() {
|
|
87
88
|
const account = useCurrentAccount();
|
|
88
89
|
const wallet = useCurrentWallet();
|
|
@@ -102,11 +103,12 @@ function WalletStatus() {
|
|
|
102
103
|
}
|
|
103
104
|
```
|
|
104
105
|
|
|
105
|
-
### 4
|
|
106
|
+
### Step 4: Execute transactions
|
|
106
107
|
|
|
107
108
|
Use the `useDAppKit` hook to sign and execute transactions:
|
|
108
109
|
|
|
109
110
|
```tsx
|
|
111
|
+
|
|
110
112
|
function TransferButton() {
|
|
111
113
|
const dAppKit = useDAppKit();
|
|
112
114
|
const account = useCurrentAccount();
|
|
@@ -136,35 +138,35 @@ function TransferButton() {
|
|
|
136
138
|
}
|
|
137
139
|
```
|
|
138
140
|
|
|
139
|
-
## Available
|
|
141
|
+
## Available hooks
|
|
140
142
|
|
|
141
|
-
| Hook
|
|
142
|
-
|
|
|
143
|
-
| [useDAppKit](/dapp-kit/react/hooks/use-dapp-kit) | Access the dApp Kit instance and actions |
|
|
144
|
-
| [useWalletConnection](/dapp-kit/react/hooks/use-wallet-connection) | Full connection state with status flags |
|
|
145
|
-
| [useCurrentAccount](/dapp-kit/react/hooks/use-current-account) | Currently selected account |
|
|
146
|
-
| [useCurrentWallet](/dapp-kit/react/hooks/use-current-wallet) | Currently connected wallet |
|
|
147
|
-
| [useCurrentNetwork](/dapp-kit/react/hooks/use-current-network) | Current network |
|
|
148
|
-
| [useCurrentClient](/dapp-kit/react/hooks/use-current-client) | SuiClient for current network |
|
|
149
|
-
| [useWallets](/dapp-kit/react/hooks/use-wallets) | List of available wallets |
|
|
143
|
+
| Hook | Description |
|
|
144
|
+
| -------------------------------------------------------------------- | ---------------------------------------- |
|
|
145
|
+
| [`useDAppKit`](/dapp-kit/react/hooks/use-dapp-kit) | Access the dApp Kit instance and actions |
|
|
146
|
+
| [`useWalletConnection`](/dapp-kit/react/hooks/use-wallet-connection) | Full connection state with status flags |
|
|
147
|
+
| [`useCurrentAccount`](/dapp-kit/react/hooks/use-current-account) | Currently selected account |
|
|
148
|
+
| [`useCurrentWallet`](/dapp-kit/react/hooks/use-current-wallet) | Currently connected wallet |
|
|
149
|
+
| [`useCurrentNetwork`](/dapp-kit/react/hooks/use-current-network) | Current network |
|
|
150
|
+
| [`useCurrentClient`](/dapp-kit/react/hooks/use-current-client) | SuiClient for current network |
|
|
151
|
+
| [`useWallets`](/dapp-kit/react/hooks/use-wallets) | List of available wallets |
|
|
150
152
|
|
|
151
153
|
## Components
|
|
152
154
|
|
|
153
|
-
| Component
|
|
154
|
-
|
|
|
155
|
-
| [ConnectButton](/dapp-kit/react/components/connect-button) | Complete wallet connection UI |
|
|
156
|
-
| [ConnectModal](/dapp-kit/react/components/connect-modal) | Standalone wallet selection modal |
|
|
157
|
-
| [DAppKitProvider](/dapp-kit/react/dapp-kit-provider) | Context provider for hooks |
|
|
155
|
+
| Component | Description |
|
|
156
|
+
| ------------------------------------------------------------ | --------------------------------- |
|
|
157
|
+
| [`ConnectButton`](/dapp-kit/react/components/connect-button) | Complete wallet connection UI |
|
|
158
|
+
| [`ConnectModal`](/dapp-kit/react/components/connect-modal) | Standalone wallet selection modal |
|
|
159
|
+
| [`DAppKitProvider`](/dapp-kit/react/dapp-kit-provider) | Context provider for hooks |
|
|
158
160
|
|
|
159
|
-
## Example
|
|
161
|
+
## Example application
|
|
160
162
|
|
|
161
163
|
See the complete
|
|
162
|
-
[React example](https://github.com/MystenLabs/ts-sdks/tree/main/packages/dapp-kit
|
|
164
|
+
[React example](https://github.com/MystenLabs/ts-sdks/tree/main/packages/dapp-kit/examples/react/simple)
|
|
163
165
|
on GitHub.
|
|
164
166
|
|
|
165
|
-
## Next
|
|
167
|
+
## Next steps
|
|
166
168
|
|
|
167
|
-
- [DAppKitProvider](/dapp-kit/react/dapp-kit-provider) - Provider configuration
|
|
169
|
+
- [`DAppKitProvider`](/dapp-kit/react/dapp-kit-provider) - Provider configuration
|
|
168
170
|
- [Hooks Reference](/dapp-kit/react/hooks) - All available hooks
|
|
169
171
|
- [Components](/dapp-kit/react/components) - UI components
|
|
170
|
-
- [Theming](/dapp-kit/theming) - Customize appearance
|
|
172
|
+
- [Theming](/dapp-kit/theming) - Customize appearance
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Vue
|
|
2
2
|
|
|
3
|
-
> Set up dApp Kit in a Vue application
|
|
3
|
+
> Set up dApp Kit in a Vue application.
|
|
4
4
|
|
|
5
5
|
This guide walks you through integrating dApp Kit into a Vue application using Web Components and
|
|
6
6
|
direct store access.
|
|
@@ -13,7 +13,7 @@ npm i @mysten/dapp-kit-core @mysten/sui @nanostores/vue
|
|
|
13
13
|
|
|
14
14
|
## Setup
|
|
15
15
|
|
|
16
|
-
### 1
|
|
16
|
+
### Step 1: Create a dApp Kit instance
|
|
17
17
|
|
|
18
18
|
```ts
|
|
19
19
|
// src/dapp-kit.ts
|
|
@@ -27,7 +27,7 @@ const GRPC_URLS = {
|
|
|
27
27
|
});
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
### 2
|
|
30
|
+
### Step 2: Register web components
|
|
31
31
|
|
|
32
32
|
Import the web components in your app entry point:
|
|
33
33
|
|
|
@@ -37,10 +37,12 @@ Import the web components in your app entry point:
|
|
|
37
37
|
createApp(App).mount('#app');
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
### 3
|
|
40
|
+
### Step 3: Use the connect button
|
|
41
41
|
|
|
42
42
|
```vue
|
|
43
|
-
<script setup lang="ts"
|
|
43
|
+
<script setup lang="ts">
|
|
44
|
+
|
|
45
|
+
</script>
|
|
44
46
|
|
|
45
47
|
<template>
|
|
46
48
|
<div>
|
|
@@ -50,12 +52,13 @@ createApp(App).mount('#app');
|
|
|
50
52
|
</template>
|
|
51
53
|
```
|
|
52
54
|
|
|
53
|
-
### 4
|
|
55
|
+
### Step 4: Access connection state
|
|
54
56
|
|
|
55
57
|
Use `@nanostores/vue` for reactive state:
|
|
56
58
|
|
|
57
59
|
```vue
|
|
58
60
|
<script setup lang="ts">
|
|
61
|
+
|
|
59
62
|
const connection = useStore(dAppKit.stores.$connection);
|
|
60
63
|
const network = useStore(dAppKit.stores.$currentNetwork);
|
|
61
64
|
</script>
|
|
@@ -74,10 +77,11 @@ const network = useStore(dAppKit.stores.$currentNetwork);
|
|
|
74
77
|
</template>
|
|
75
78
|
```
|
|
76
79
|
|
|
77
|
-
### 5
|
|
80
|
+
### Step 5: Execute transactions
|
|
78
81
|
|
|
79
82
|
```vue
|
|
80
83
|
<script setup lang="ts">
|
|
84
|
+
|
|
81
85
|
const connection = useStore(dAppKit.stores.$connection);
|
|
82
86
|
|
|
83
87
|
async function handleTransfer() {
|
|
@@ -107,10 +111,11 @@ async function handleTransfer() {
|
|
|
107
111
|
</template>
|
|
108
112
|
```
|
|
109
113
|
|
|
110
|
-
## Complete
|
|
114
|
+
## Complete example
|
|
111
115
|
|
|
112
116
|
```vue
|
|
113
117
|
<script setup lang="ts">
|
|
118
|
+
|
|
114
119
|
const connection = useStore(dAppKit.stores.$connection);
|
|
115
120
|
const network = useStore(dAppKit.stores.$currentNetwork);
|
|
116
121
|
|
|
@@ -150,7 +155,7 @@ async function handleTransfer() {
|
|
|
150
155
|
</template>
|
|
151
156
|
```
|
|
152
157
|
|
|
153
|
-
## Web
|
|
158
|
+
## Web components
|
|
154
159
|
|
|
155
160
|
Vue works with dApp Kit's Web Components through property binding:
|
|
156
161
|
|
|
@@ -161,9 +166,9 @@ Vue works with dApp Kit's Web Components through property binding:
|
|
|
161
166
|
|
|
162
167
|
See [Web Components](/dapp-kit/web-components/connect-button) for full documentation.
|
|
163
168
|
|
|
164
|
-
## Available
|
|
169
|
+
## Available stores
|
|
165
170
|
|
|
166
|
-
Access these stores
|
|
171
|
+
Access these stores through `dAppKit.stores`:
|
|
167
172
|
|
|
168
173
|
| Store | Description |
|
|
169
174
|
| ----------------- | ------------------------------------------------- |
|
|
@@ -174,15 +179,15 @@ Access these stores via `dAppKit.stores`:
|
|
|
174
179
|
|
|
175
180
|
See [State Management](/dapp-kit/state) for full documentation.
|
|
176
181
|
|
|
177
|
-
## Example
|
|
182
|
+
## Example application
|
|
178
183
|
|
|
179
184
|
See the complete
|
|
180
|
-
[Vue example](https://github.com/MystenLabs/ts-sdks/tree/main/packages/dapp-kit
|
|
185
|
+
[Vue example](https://github.com/MystenLabs/ts-sdks/tree/main/packages/dapp-kit/examples/vue/simple)
|
|
181
186
|
on GitHub.
|
|
182
187
|
|
|
183
|
-
## Next
|
|
188
|
+
## Next steps
|
|
184
189
|
|
|
185
190
|
- [Web Components](/dapp-kit/web-components/connect-button) - Component documentation
|
|
186
191
|
- [State Management](/dapp-kit/state) - Store details
|
|
187
192
|
- [Actions](/dapp-kit/actions/connect-wallet) - All available actions
|
|
188
|
-
- [Theming](/dapp-kit/theming) - Customize appearance
|
|
193
|
+
- [Theming](/dapp-kit/theming) - Customize appearance
|
package/docs/index.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Sui dApp Kit
|
|
2
2
|
|
|
3
|
-
> Build Sui
|
|
3
|
+
> Build Sui apps with framework-agnostic core and React bindings.
|
|
4
4
|
|
|
5
|
-
> **Note:** **Migrating from @mysten/dapp-kit?** If you're currently using the legacy
|
|
6
|
-
>
|
|
7
|
-
>
|
|
5
|
+
> **Note:** **Migrating from @mysten/dapp-kit?** If you're currently using the legacy `@mysten/dapp-kit`
|
|
6
|
+
> package, check out our [Migration Guide](/sui/migrations/sui-2.0/dapp-kit) to upgrade to the new
|
|
7
|
+
> packages with gRPC and GraphQL support.
|
|
8
8
|
|
|
9
9
|
The Sui dApp Kit provides tools and components for building decentralized applications on the Sui
|
|
10
10
|
network. The SDK consists of two packages that work together:
|
|
@@ -32,7 +32,7 @@ React bindings for the core package:
|
|
|
32
32
|
|
|
33
33
|
Choose the installation method based on your framework:
|
|
34
34
|
|
|
35
|
-
### For React
|
|
35
|
+
### For React applications
|
|
36
36
|
|
|
37
37
|
```sh npm2yarn
|
|
38
38
|
npm i @mysten/dapp-kit-react @mysten/sui
|
|
@@ -44,7 +44,7 @@ npm i @mysten/dapp-kit-react @mysten/sui
|
|
|
44
44
|
npm i @mysten/dapp-kit-core @mysten/sui
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
## Getting
|
|
47
|
+
## Getting started
|
|
48
48
|
|
|
49
49
|
Check the framework-specific guides:
|
|
50
50
|
|
|
@@ -52,7 +52,7 @@ Check the framework-specific guides:
|
|
|
52
52
|
- [Next.js](/dapp-kit/getting-started/next-js)
|
|
53
53
|
- [Vue](/dapp-kit/getting-started/vue)
|
|
54
54
|
|
|
55
|
-
## Legacy
|
|
55
|
+
## Legacy package
|
|
56
56
|
|
|
57
57
|
### @mysten/dapp-kit (Legacy)
|
|
58
58
|
|
|
@@ -65,6 +65,6 @@ The original React-focused version of the dApp Kit. This package provides:
|
|
|
65
65
|
- Integration with TanStack React Query
|
|
66
66
|
- Comprehensive wallet state management
|
|
67
67
|
|
|
68
|
-
> **Warning:** **Deprecated JSON RPC Only**: This legacy package only works with the deprecated JSON
|
|
69
|
-
>
|
|
70
|
-
> `@mysten/dapp-kit-core` and `@mysten/dapp-kit-react`.
|
|
68
|
+
> **Warning:** **Deprecated JSON RPC Only**: This legacy package only works with the deprecated JSON RPC API and
|
|
69
|
+
> will not be updated to support gRPC or GraphQL. All new projects should use
|
|
70
|
+
> `@mysten/dapp-kit-core` and `@mysten/dapp-kit-react`.
|
package/docs/llms-index.md
CHANGED
|
@@ -1,34 +1,33 @@
|
|
|
1
1
|
# dApp Kit
|
|
2
|
-
|
|
3
2
|
> Build Sui dApps with @mysten/dapp-kit-core and @mysten/dapp-kit-react
|
|
4
3
|
|
|
5
|
-
- [Sui dApp Kit](
|
|
6
|
-
- [@mysten/create-dapp](./getting-started/create-dapp.md): Create a Sui
|
|
7
|
-
- [React](./getting-started/react.md): Set up dApp Kit in a React application
|
|
8
|
-
- [Next.js](./getting-started/next-js.md): Set up dApp Kit in a Next.js application
|
|
9
|
-
- [Vue](./getting-started/vue.md): Set up dApp Kit in a Vue application
|
|
10
|
-
- [DApp Kit Instance](./dapp-kit-instance.md): Create and configure a DAppKit instance for wallet
|
|
11
|
-
|
|
12
|
-
- [
|
|
13
|
-
- [
|
|
14
|
-
- [
|
|
15
|
-
- [Sign
|
|
16
|
-
|
|
17
|
-
- [
|
|
18
|
-
|
|
19
|
-
- [
|
|
20
|
-
- [
|
|
21
|
-
- [
|
|
22
|
-
- [
|
|
23
|
-
- [
|
|
24
|
-
- [
|
|
25
|
-
- [
|
|
26
|
-
|
|
27
|
-
- [
|
|
28
|
-
|
|
29
|
-
- [Connect
|
|
30
|
-
- [Connect
|
|
31
|
-
|
|
32
|
-
- [Connect Modal](./web-components/connect-modal.md): Framework-agnostic web component for wallet
|
|
33
|
-
|
|
34
|
-
- [
|
|
4
|
+
- [Sui dApp Kit](..md): Build Sui apps with framework-agnostic core and React bindings.
|
|
5
|
+
- [@mysten/create-dapp](./getting-started/create-dapp.md): Create a Sui app with one command using the create-dapp CLI scaffolding tool.
|
|
6
|
+
- [React](./getting-started/react.md): Set up dApp Kit in a React application.
|
|
7
|
+
- [Next.js](./getting-started/next-js.md): Set up dApp Kit in a Next.js application.
|
|
8
|
+
- [Vue](./getting-started/vue.md): Set up dApp Kit in a Vue application.
|
|
9
|
+
- [DApp Kit Instance](./dapp-kit-instance.md): Create and configure a DAppKit instance for wallet and client management
|
|
10
|
+
- [State](./state.md): Access and subscribe to wallet connection state in dApp Kit.
|
|
11
|
+
- [Connect Wallet](./actions/connect-wallet.md): Programmatically connect to a Sui wallet using the dApp Kit connectWallet action.
|
|
12
|
+
- [Disconnect Wallet](./actions/disconnect-wallet.md): Programmatically disconnect from a Sui wallet using the dApp Kit disconnectWallet action.
|
|
13
|
+
- [Sign and Execute Transaction](./actions/sign-and-execute-transaction.md): Sign and execute a transaction on the Sui network using the connected wallet.
|
|
14
|
+
- [Sign Personal Message](./actions/sign-personal-message.md): Sign an arbitrary message with the connected wallet for authentication or proof of ownership.
|
|
15
|
+
- [Sign Transaction](./actions/sign-transaction.md): Sign a Sui transaction without executing it for deferred or multi-signature scenarios.
|
|
16
|
+
- [Switch Account](./actions/switch-account.md): Switch the active account in the connected wallet using the dApp Kit switchAccount action.
|
|
17
|
+
- [Switch Network](./actions/switch-network.md): Switch the active network for the dApp Kit instance between mainnet, testnet, and other networks.
|
|
18
|
+
- [DAppKitProvider](./react/dapp-kit-provider.md): React context provider that makes dApp Kit available throughout your application.
|
|
19
|
+
- [React Hooks](./react/hooks.md): React hooks for accessing dApp Kit state and actions in Sui applications.
|
|
20
|
+
- [useDAppKit](./react/hooks/use-dapp-kit.md): React hook to access the full dApp Kit instance for calling actions directly.
|
|
21
|
+
- [useCurrentAccount](./react/hooks/use-current-account.md): React hook to get the currently selected wallet account in a Sui dApp.
|
|
22
|
+
- [useCurrentClient](./react/hooks/use-current-client.md): React hook to get the current Sui client instance for the active network.
|
|
23
|
+
- [useCurrentNetwork](./react/hooks/use-current-network.md): React hook to get the currently selected Sui network in dApp Kit.
|
|
24
|
+
- [useCurrentWallet](./react/hooks/use-current-wallet.md): React hook to get the currently connected wallet in a Sui dApp.
|
|
25
|
+
- [useWalletConnection](./react/hooks/use-wallet-connection.md): React hook to manage wallet connection status and information in a Sui dApp.
|
|
26
|
+
- [useWallets](./react/hooks/use-wallets.md): React hook to list all available Sui wallets detected by dApp Kit.
|
|
27
|
+
- [React Components](./react/components.md): Pre-built React UI components for wallet interaction in Sui dApps.
|
|
28
|
+
- [Connect Button](./react/components/connect-button.md): React button component for connecting and disconnecting Sui wallets.
|
|
29
|
+
- [Connect Modal](./react/components/connect-modal.md): React modal component for selecting and connecting to a Sui wallet.
|
|
30
|
+
- [Connect Button](./web-components/connect-button.md): Framework-agnostic web component providing a complete wallet connection UI for Sui dApps.
|
|
31
|
+
- [Connect Modal](./web-components/connect-modal.md): Framework-agnostic web component for wallet selection and connection in Sui dApps.
|
|
32
|
+
- [Theming](./theming.md): Customize the appearance of dApp Kit UI components.
|
|
33
|
+
- [Sui dApp Kit (Legacy)](./legacy.md): Legacy dApp Kit API reference for the deprecated @mysten/dapp-kit package using JSON RPC.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Connect Button
|
|
2
2
|
|
|
3
|
-
> React button component for
|
|
3
|
+
> React button component for connecting and disconnecting Sui wallets.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
- **sortFn** (optional) - Function to sort available wallets
|
|
27
27
|
- Type: `(a: UiWallet, b: UiWallet) => number`
|
|
28
28
|
|
|
29
|
-
## Custom
|
|
29
|
+
## Custom button text
|
|
30
30
|
|
|
31
31
|
Use the slot to customize the button content when disconnected:
|
|
32
32
|
|
|
@@ -36,7 +36,7 @@ Use the slot to customize the button content when disconnected:
|
|
|
36
36
|
</ConnectButton>
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
## Server-
|
|
39
|
+
## Server-side rendering (SSR)
|
|
40
40
|
|
|
41
41
|
The `<ConnectButton />` component can be only client-side rendered, as wallets are detected in the
|
|
42
|
-
browser. For Next.js guide see [here](/dapp-kit/getting-started/next-js).
|
|
42
|
+
browser. For Next.js guide see [here](/dapp-kit/getting-started/next-js).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Connect Modal
|
|
2
2
|
|
|
3
|
-
> React modal component for wallet
|
|
3
|
+
> React modal component for selecting and connecting to a Sui wallet.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
/>
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
## Modal
|
|
39
|
+
## Modal states
|
|
40
40
|
|
|
41
41
|
The modal displays different views based on connection status:
|
|
42
42
|
|
|
@@ -45,7 +45,7 @@ The modal displays different views based on connection status:
|
|
|
45
45
|
- **Error**: Shows error message with retry option when connection fails
|
|
46
46
|
- **Request Cancelled**: Appears when user cancels the wallet connection request
|
|
47
47
|
|
|
48
|
-
## Server-
|
|
48
|
+
## Server-side rendering (SSR)
|
|
49
49
|
|
|
50
50
|
The `<ConnectModal />` component can be only client-side rendered, as wallets are detected in the
|
|
51
|
-
browser. For Next.js guide see [here](/dapp-kit/getting-started/next-js).
|
|
51
|
+
browser. For Next.js guide see [here](/dapp-kit/getting-started/next-js).
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# React Components
|
|
2
2
|
|
|
3
|
-
> Pre-built React UI components for wallet interaction
|
|
3
|
+
> Pre-built React UI components for wallet interaction in Sui dApps.
|
|
4
4
|
|
|
5
5
|
The `@mysten/dapp-kit-react` package provides pre-built React components for common wallet
|
|
6
6
|
interactions.
|
|
7
7
|
|
|
8
|
-
## Available
|
|
8
|
+
## Available components
|
|
9
9
|
|
|
10
10
|
- [`ConnectButton`](/dapp-kit/react/components/connect-button) - A button that opens the wallet
|
|
11
11
|
connection modal and displays account info when connected
|
|
12
12
|
- [`ConnectModal`](/dapp-kit/react/components/connect-modal) - A modal dialog for selecting and
|
|
13
|
-
connecting to a wallet
|
|
13
|
+
connecting to a wallet
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# DAppKitProvider
|
|
2
2
|
|
|
3
|
-
> React context provider
|
|
3
|
+
> React context provider that makes dApp Kit available throughout your application.
|
|
4
4
|
|
|
5
5
|
The `DAppKitProvider` is a React context provider that makes your dApp Kit instance available
|
|
6
6
|
throughout your React application. It must wrap any components that use dApp Kit hooks.
|
|
7
7
|
|
|
8
|
-
## Basic
|
|
8
|
+
## Basic usage
|
|
9
9
|
|
|
10
10
|
```tsx
|
|
11
11
|
|
|
@@ -21,9 +21,9 @@ throughout your React application. It must wrap any components that use dApp Kit
|
|
|
21
21
|
|
|
22
22
|
- **dAppKit**: The dApp Kit instance created with `createDAppKit`
|
|
23
23
|
|
|
24
|
-
## Provider
|
|
24
|
+
## Provider setup patterns
|
|
25
25
|
|
|
26
|
-
### With
|
|
26
|
+
### With custom configuration
|
|
27
27
|
|
|
28
28
|
```tsx
|
|
29
29
|
|
|
@@ -54,7 +54,7 @@ declare module '@mysten/dapp-kit-react' {
|
|
|
54
54
|
}
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
## Using
|
|
57
|
+
## Using hooks inside the provider
|
|
58
58
|
|
|
59
59
|
Once your app is wrapped with `DAppKitProvider`, you can use any dApp Kit hooks in child components:
|
|
60
60
|
|
|
@@ -79,8 +79,8 @@ Once your app is wrapped with `DAppKitProvider`, you can use any dApp Kit hooks
|
|
|
79
79
|
> All dApp Kit hooks must be used within components that are descendants of `DAppKitProvider`. Using
|
|
80
80
|
> them outside will result in an error.
|
|
81
81
|
|
|
82
|
-
## Server-
|
|
82
|
+
## Server-side rendering (SSR)
|
|
83
83
|
|
|
84
84
|
While `DAppKitProvider` itself is SSR-safe, components that interact with wallets should be
|
|
85
85
|
client-side rendered, as wallets are detected in the browser. For Next.js guide see
|
|
86
|
-
[here](/dapp-kit/getting-started/next-js).
|
|
86
|
+
[here](/dapp-kit/getting-started/next-js).
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
# React Hooks
|
|
2
2
|
|
|
3
|
-
> React hooks for accessing dApp Kit state and actions
|
|
3
|
+
> React hooks for accessing dApp Kit state and actions in Sui applications.
|
|
4
4
|
|
|
5
5
|
The `@mysten/dapp-kit-react` package provides a set of hooks for interacting with wallets and the
|
|
6
6
|
Sui blockchain in React applications.
|
|
7
7
|
|
|
8
8
|
> **Warning:** All dApp Kit hooks must be used within components that are descendants of
|
|
9
|
-
> [DAppKitProvider](/dapp-kit/react/dapp-kit-provider). Using them outside will result in an
|
|
9
|
+
> [`DAppKitProvider`](/dapp-kit/react/dapp-kit-provider). Using them outside will result in an
|
|
10
|
+
> error.
|
|
10
11
|
|
|
11
|
-
## Available
|
|
12
|
+
## Available hooks
|
|
12
13
|
|
|
13
14
|
- [`useDAppKit`](/dapp-kit/react/hooks/use-dapp-kit) - Access the dApp Kit instance for calling
|
|
14
15
|
actions directly
|
|
@@ -22,4 +23,4 @@ Sui blockchain in React applications.
|
|
|
22
23
|
wallet
|
|
23
24
|
- [`useWalletConnection`](/dapp-kit/react/hooks/use-wallet-connection) - Get wallet connection
|
|
24
25
|
status and actions
|
|
25
|
-
- [`useWallets`](/dapp-kit/react/hooks/use-wallets) - Get all available wallets
|
|
26
|
+
- [`useWallets`](/dapp-kit/react/hooks/use-wallets) - Get all available wallets
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# useCurrentAccount
|
|
2
2
|
|
|
3
|
-
> React hook to get the
|
|
3
|
+
> React hook to get the currently selected wallet account in a Sui dApp.
|
|
4
4
|
|
|
5
5
|
The `useCurrentAccount` hook provides access to the currently selected account.
|
|
6
6
|
|
|
7
7
|
> **Warning:** All dApp Kit hooks must be used within components that are descendants of
|
|
8
|
-
> [DAppKitProvider](../dapp-kit-provider). Using them outside will result in an error.
|
|
8
|
+
> [`DAppKitProvider`](../dapp-kit-provider). Using them outside will result in an error.
|
|
9
9
|
|
|
10
10
|
## Usage
|
|
11
11
|
|
|
@@ -26,8 +26,8 @@ The `useCurrentAccount` hook provides access to the currently selected account.
|
|
|
26
26
|
}
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
## Return
|
|
29
|
+
## Return value
|
|
30
30
|
|
|
31
31
|
```tsx
|
|
32
32
|
UiWalletAccount | null;
|
|
33
|
-
```
|
|
33
|
+
```
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# useCurrentClient
|
|
2
2
|
|
|
3
|
-
> React hook to get the current Sui client instance
|
|
3
|
+
> React hook to get the current Sui client instance for the active network.
|
|
4
4
|
|
|
5
5
|
The `useCurrentClient` hook provides access to the blockchain client instance for the current
|
|
6
6
|
network.
|
|
7
7
|
|
|
8
|
-
> **Note:** By default, this returns a `SuiClient` instance when using the standard setup. However,
|
|
9
|
-
>
|
|
10
|
-
>
|
|
8
|
+
> **Note:** By default, this returns a `SuiClient` instance when using the standard setup. However, the dApp
|
|
9
|
+
> Kit supports any client that implements the Sui core API, making it flexible for different
|
|
10
|
+
> blockchain implementations.
|
|
11
11
|
|
|
12
12
|
> **Warning:** All dApp Kit hooks must be used within components that are descendants of
|
|
13
|
-
> [DAppKitProvider](../dapp-kit-provider). Using them outside will result in an error.
|
|
13
|
+
> [`DAppKitProvider`](../dapp-kit-provider). Using them outside will result in an error.
|
|
14
14
|
|
|
15
15
|
## Usage
|
|
16
16
|
|
|
@@ -29,8 +29,8 @@ network.
|
|
|
29
29
|
}
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
## Return
|
|
32
|
+
## Return value
|
|
33
33
|
|
|
34
34
|
```tsx
|
|
35
35
|
SuiClient;
|
|
36
|
-
```
|
|
36
|
+
```
|