@mysten/docs 0.1.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 (108) hide show
  1. package/README.md +24 -0
  2. package/dist/bcs/index.md +358 -0
  3. package/dist/bcs/llms-index.md +4 -0
  4. package/dist/codegen/index.md +441 -0
  5. package/dist/codegen/llms-index.md +4 -0
  6. package/dist/dapp-kit/actions/connect-wallet.md +69 -0
  7. package/dist/dapp-kit/actions/disconnect-wallet.md +38 -0
  8. package/dist/dapp-kit/actions/sign-and-execute-transaction.md +96 -0
  9. package/dist/dapp-kit/actions/sign-personal-message.md +58 -0
  10. package/dist/dapp-kit/actions/sign-transaction.md +65 -0
  11. package/dist/dapp-kit/actions/switch-account.md +37 -0
  12. package/dist/dapp-kit/actions/switch-network.md +37 -0
  13. package/dist/dapp-kit/dapp-kit-instance.md +162 -0
  14. package/dist/dapp-kit/getting-started/create-dapp.md +151 -0
  15. package/dist/dapp-kit/getting-started/next-js.md +162 -0
  16. package/dist/dapp-kit/getting-started/react.md +172 -0
  17. package/dist/dapp-kit/getting-started/vue.md +193 -0
  18. package/dist/dapp-kit/index.md +70 -0
  19. package/dist/dapp-kit/llms-index.md +26 -0
  20. package/dist/dapp-kit/react/components/connect-button.md +42 -0
  21. package/dist/dapp-kit/react/components/connect-modal.md +51 -0
  22. package/dist/dapp-kit/react/components/index.md +13 -0
  23. package/dist/dapp-kit/react/dapp-kit-provider.md +86 -0
  24. package/dist/dapp-kit/react/hooks/index.md +25 -0
  25. package/dist/dapp-kit/react/hooks/use-current-account.md +33 -0
  26. package/dist/dapp-kit/react/hooks/use-current-client.md +36 -0
  27. package/dist/dapp-kit/react/hooks/use-current-network.md +28 -0
  28. package/dist/dapp-kit/react/hooks/use-current-wallet.md +36 -0
  29. package/dist/dapp-kit/react/hooks/use-dapp-kit.md +100 -0
  30. package/dist/dapp-kit/react/hooks/use-wallet-connection.md +48 -0
  31. package/dist/dapp-kit/react/hooks/use-wallets.md +33 -0
  32. package/dist/dapp-kit/state.md +169 -0
  33. package/dist/dapp-kit/theming.md +196 -0
  34. package/dist/dapp-kit/web-components/connect-button.md +89 -0
  35. package/dist/dapp-kit/web-components/connect-modal.md +177 -0
  36. package/dist/kiosk/advanced-examples.md +101 -0
  37. package/dist/kiosk/from-v1.md +320 -0
  38. package/dist/kiosk/index.md +22 -0
  39. package/dist/kiosk/kiosk-client/introduction.md +52 -0
  40. package/dist/kiosk/kiosk-client/kiosk-transaction/examples.md +119 -0
  41. package/dist/kiosk/kiosk-client/kiosk-transaction/kiosk-transaction.md +103 -0
  42. package/dist/kiosk/kiosk-client/kiosk-transaction/managing.md +235 -0
  43. package/dist/kiosk/kiosk-client/kiosk-transaction/purchasing.md +110 -0
  44. package/dist/kiosk/kiosk-client/querying.md +237 -0
  45. package/dist/kiosk/kiosk-client/transfer-policy-transaction/introduction.md +79 -0
  46. package/dist/kiosk/kiosk-client/transfer-policy-transaction/using-the-manager.md +115 -0
  47. package/dist/kiosk/llms-index.md +8 -0
  48. package/dist/llms-index.md +125 -0
  49. package/dist/payment-kit/getting-started.md +256 -0
  50. package/dist/payment-kit/index.md +132 -0
  51. package/dist/payment-kit/llms-index.md +8 -0
  52. package/dist/payment-kit/payment-kit-sdk.md +747 -0
  53. package/dist/payment-kit/payment-processing.md +372 -0
  54. package/dist/payment-kit/registry-management.md +529 -0
  55. package/dist/seal/index.md +85 -0
  56. package/dist/seal/llms-index.md +4 -0
  57. package/dist/slush-wallet/dapp.md +95 -0
  58. package/dist/slush-wallet/deep-linking.md +465 -0
  59. package/dist/slush-wallet/index.md +7 -0
  60. package/dist/slush-wallet/llms-index.md +6 -0
  61. package/dist/sui/bcs.md +134 -0
  62. package/dist/sui/clients/core.md +606 -0
  63. package/dist/sui/clients/graphql.md +101 -0
  64. package/dist/sui/clients/grpc.md +155 -0
  65. package/dist/sui/clients/index.md +95 -0
  66. package/dist/sui/clients/json-rpc.md +239 -0
  67. package/dist/sui/cryptography/keypairs.md +267 -0
  68. package/dist/sui/cryptography/multisig.md +194 -0
  69. package/dist/sui/cryptography/passkey.md +111 -0
  70. package/dist/sui/cryptography/webcrypto-signer.md +81 -0
  71. package/dist/sui/executors.md +148 -0
  72. package/dist/sui/faucet.md +26 -0
  73. package/dist/sui/hello-sui.md +115 -0
  74. package/dist/sui/index.md +53 -0
  75. package/dist/sui/install.md +61 -0
  76. package/dist/sui/llm-docs.md +32 -0
  77. package/dist/sui/llms-index.md +44 -0
  78. package/dist/sui/migrations/0.38.md +58 -0
  79. package/dist/sui/migrations/sui-1.0.md +455 -0
  80. package/dist/sui/migrations/sui-2.0/agent-prompt.md +42 -0
  81. package/dist/sui/migrations/sui-2.0/dapp-kit.md +350 -0
  82. package/dist/sui/migrations/sui-2.0/deepbook-v3.md +33 -0
  83. package/dist/sui/migrations/sui-2.0/index.md +158 -0
  84. package/dist/sui/migrations/sui-2.0/json-rpc-migration.md +386 -0
  85. package/dist/sui/migrations/sui-2.0/kiosk.md +120 -0
  86. package/dist/sui/migrations/sui-2.0/sdk-maintainers.md +90 -0
  87. package/dist/sui/migrations/sui-2.0/seal.md +14 -0
  88. package/dist/sui/migrations/sui-2.0/sui.md +341 -0
  89. package/dist/sui/migrations/sui-2.0/suins.md +43 -0
  90. package/dist/sui/migrations/sui-2.0/wallet-builders.md +66 -0
  91. package/dist/sui/migrations/sui-2.0/walrus.md +41 -0
  92. package/dist/sui/migrations/sui-2.0/zksend.md +95 -0
  93. package/dist/sui/plugins.md +258 -0
  94. package/dist/sui/sdk-building.md +344 -0
  95. package/dist/sui/transaction-building/basics.md +299 -0
  96. package/dist/sui/transaction-building/gas.md +62 -0
  97. package/dist/sui/transaction-building/intents.md +62 -0
  98. package/dist/sui/transaction-building/offline.md +73 -0
  99. package/dist/sui/transaction-building/sponsored-transactions.md +22 -0
  100. package/dist/sui/utils/derived_objects.md +59 -0
  101. package/dist/sui/utils/index.md +52 -0
  102. package/dist/sui/zklogin.md +83 -0
  103. package/dist/walrus/index.md +527 -0
  104. package/dist/walrus/llms-index.md +4 -0
  105. package/dist/zksend/index.md +27 -0
  106. package/dist/zksend/link-builder.md +192 -0
  107. package/dist/zksend/llms-index.md +5 -0
  108. package/package.json +66 -0
@@ -0,0 +1,65 @@
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
+
13
+ const dAppKit = createDAppKit({
14
+ /* config */
15
+ });
16
+
17
+ const tx = new Transaction();
18
+ // No need to manually set sender - it's done automatically
19
+ tx.transferObjects([coinWithBalance({ balance: 123 })], '0xrecipient...');
20
+
21
+ // Sign the transaction without executing it
22
+ const { bytes, signature } = await dAppKit.signTransaction({
23
+ transaction: tx,
24
+ });
25
+ ```
26
+
27
+ ## Parameters
28
+
29
+ - **`transaction`** - `Transaction | string` - The transaction to sign. Can be either a Transaction
30
+ instance or base64-encoded bcs bytes for the transaction.
31
+ - **`signal`** (optional) - `AbortSignal` - An abort signal to cancel the signing request.
32
+
33
+ ## Return Value
34
+
35
+ Returns a `Promise` that resolves to an object containing:
36
+
37
+ - **`bytes`** - `string` - The signed transaction as a base64-encoded BCS string
38
+ - **`signature`** - `string` - The signature as a base64-encoded string
39
+
40
+ ```typescript
41
+ const result = await dAppKit.signTransaction({ transaction });
42
+ console.log('Signed transaction bytes:', result.bytes);
43
+ console.log('Signature:', result.signature);
44
+ ```
45
+
46
+ ## Transaction Building
47
+
48
+ When passing a Transaction instance, the action automatically:
49
+
50
+ 1. Sets the sender address if not already set
51
+ 2. Builds the transaction using the current network's client
52
+ 3. Converts it to the appropriate format for the wallet
53
+
54
+ ## Wallet Compatibility
55
+
56
+ - The action transparently handles both `sui:signTransaction` and `sui:signTransactionBlock`
57
+ wallet-standard features
58
+
59
+ ```typescript
60
+ // The action automatically detects and uses the appropriate method
61
+ // No special configuration needed
62
+ const result = await dAppKit.signTransaction({
63
+ transaction: tx,
64
+ });
65
+ ```
@@ -0,0 +1,37 @@
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 your
9
+ > 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
+
20
+ const dAppKit = createDAppKit({
21
+ /* config */
22
+ });
23
+
24
+ // Switch to a different account
25
+ dAppKit.switchAccount({
26
+ account: anotherAccount, // UiWalletAccount from the connected wallet
27
+ });
28
+ ```
29
+
30
+ ## Parameters
31
+
32
+ - **`account`** - `UiWalletAccount` - The account to switch to. Must be an account that belongs to
33
+ the currently connected wallet.
34
+
35
+ ## Return Value
36
+
37
+ Returns `void`. The action completes synchronously and updates the connection state immediately.
@@ -0,0 +1,37 @@
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 affected by
9
+ > this change, and wallets are not notified when the network changes in the dApp.
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+
15
+ const GRPC_URLS = {
16
+ mainnet: 'https://fullnode.mainnet.sui.io:443',
17
+ testnet: 'https://fullnode.testnet.sui.io:443',
18
+ } as const;
19
+
20
+ const dAppKit = createDAppKit({
21
+ networks: ['mainnet', 'testnet'],
22
+ defaultNetwork: 'mainnet',
23
+ createClient: (network) => new SuiGrpcClient({ network, baseUrl: GRPC_URLS[network] }),
24
+ });
25
+
26
+ // Switch to a different network
27
+ dAppKit.switchNetwork('testnet');
28
+ ```
29
+
30
+ ## Parameters
31
+
32
+ - **`network`** - `TNetworks[number]` - The network to switch to. Must be one of the networks
33
+ configured when creating the dApp Kit instance.
34
+
35
+ ## Return Value
36
+
37
+ Returns `void`. The action completes synchronously and updates the network state immediately.
@@ -0,0 +1,162 @@
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, and all hooks will be properly typed
27
+ > 2. Pass the dAppKit instance explicitly to each hook: `useWalletConnection({ dAppKit })`
28
+
29
+ This instance provides:
30
+
31
+ - Wallet connection management
32
+ - Network switching capabilities
33
+ - Client access for blockchain interactions
34
+ - State stores for reactive updates
35
+
36
+ ## Parameters
37
+
38
+ - **autoConnect** (optional) - Enables automatically connecting to the most recently used wallet
39
+ account (default: `true`)
40
+ - **networks** - A list of networks supported by the application (e.g. `['mainnet', 'testnet']`)
41
+ - **defaultNetwork** (optional) - Initial network to use (default: first network in the array)
42
+ - **createClient** - Creates a new client instance for the given network
43
+ - **enableBurnerWallet** (optional) - Enable development-only burner wallet (default: `false`)
44
+ - **storage** (optional) - Configures how the most recently connected to wallet account is stored
45
+ (default: `localStorage`, set to `null` to disable)
46
+ - **storageKey** (optional) - The key to use to store the most recently connected wallet account
47
+ (default: `'mysten-dapp-kit:selected-wallet-and-address'`)
48
+ - **walletInitializers** (optional) - A list of wallet initializers used for registering additional
49
+ wallet standard wallets.
50
+ - **slushWalletConfig** (optional) - Configuration for Slush wallet (set to `null` to disable the
51
+ wallet)
52
+
53
+ ## Return Value
54
+
55
+ ```ts
56
+ {
57
+ // Actions
58
+ connectWallet: (args: { wallet: UiWallet; account?: UiWalletAccount }) => Promise<{ accounts: UiWalletAccount[]; }>;
59
+ disconnectWallet: () => Promise<void>;
60
+ switchAccount: (args: { account: UiWalletAccount }) => Promise<void>;
61
+ switchNetwork: (network: string) => void;
62
+ signTransaction: (args: { transaction: Transaction | string; signal?: AbortSignal }) => Promise<SignedTransaction>;
63
+ signAndExecuteTransaction: (args: { transaction: Transaction | string; signal?: AbortSignal }) => Promise<TransactionResult>;
64
+ signPersonalMessage: (args: { message: Uint8Array }) => Promise<SignedPersonalMessage>;
65
+
66
+ // Properties
67
+ networks: string[];
68
+ stores: {
69
+ $wallets: DAppKitStores['$compatibleWallets'];
70
+ $connection: DAppKitStores['$connection'];
71
+ $currentNetwork: ReadableAtom<TNetworks[number]>;
72
+ $currentClient: ReadableAtom<Client>;
73
+ };
74
+ getClient: (network?: string) => Client;
75
+ }
76
+ ```
77
+
78
+ Read more about [actions](./actions/connect-wallet) and [stores](./state).
79
+
80
+ ## Basic Usage
81
+
82
+ ```ts
83
+ // dapp-kit.ts
84
+
85
+ const GRPC_URLS = {
86
+ testnet: 'https://fullnode.testnet.sui.io:443',
87
+ };
88
+
89
+ networks: ['testnet'],
90
+ createClient: (network) => new SuiGrpcClient({ network, baseUrl: GRPC_URLS[network] }),
91
+ });
92
+ ```
93
+
94
+ ```ts
95
+ // connect-wallet-and-log.ts
96
+
97
+ wallet,
98
+ account,
99
+ }: {
100
+ wallet: UiWallet;
101
+ account: UiWalletAccount;
102
+ }) {
103
+ const result = await dAppKit.connectWallet({
104
+ wallet,
105
+ account,
106
+ });
107
+ console.log('Connected accounts:', result.accounts);
108
+ }
109
+ ```
110
+
111
+ > If you use the React bindings, see [Getting Started in React](./getting-started/react) and
112
+ > [DAppKitProvider](./react/dapp-kit-provider).
113
+
114
+ ## Development Configuration
115
+
116
+ For development environments, enable the burner wallet:
117
+
118
+ ```typescript
119
+
120
+ networks: ['localnet'],
121
+ defaultNetwork: 'localnet',
122
+ createClient: () => new SuiGrpcClient({ network: 'localnet', baseUrl: 'http://127.0.0.1:9000' }),
123
+ enableBurnerWallet: true, // Dev-only feature
124
+ });
125
+ ```
126
+
127
+ ## Auto-Connect Behavior
128
+
129
+ By default, dApp Kit automatically reconnects to the previously connected wallet.
130
+
131
+ ### Disabling Auto-Connect
132
+
133
+ ```typescript
134
+
135
+ networks: ['mainnet'],
136
+ createClient: () =>
137
+ new SuiGrpcClient({ network: 'mainnet', baseUrl: 'https://fullnode.mainnet.sui.io:443' }),
138
+ autoConnect: false,
139
+ });
140
+ ```
141
+
142
+ ## Custom Wallet Integration
143
+
144
+ Add support for custom wallets using wallet initializers:
145
+
146
+ ```typescript
147
+
148
+ networks: ['mainnet'],
149
+ createClient: () =>
150
+ new SuiGrpcClient({ network: 'mainnet', baseUrl: 'https://fullnode.mainnet.sui.io:443' }),
151
+ walletInitializers: [
152
+ {
153
+ id: 'Custom Wallets',
154
+ initialize() {
155
+ const wallets = [new CustomWallet()];
156
+ const walletsApi = getWallets();
157
+ return { unregister: walletsApi.register(...wallets) };
158
+ },
159
+ },
160
+ ],
161
+ });
162
+ ```
@@ -0,0 +1,151 @@
1
+ # @mysten/create-dapp
2
+
3
+ > Create a Sui dApp with one command
4
+
5
+ `@mysten/create-dapp` is a CLI tool that scaffolds a complete Sui dApp project with best practices
6
+ built in.
7
+
8
+ ## Quick Start
9
+
10
+ ```sh npm2yarn
11
+ npm create @mysten/dapp
12
+ ```
13
+
14
+ The CLI prompts you to choose a template and project name, then creates a ready-to-run project.
15
+
16
+ ## Templates
17
+
18
+ ### react-client-dapp
19
+
20
+ A basic React dApp that demonstrates wallet connection and fetching owned objects:
21
+
22
+ - Wallet connection with `ConnectButton`
23
+ - Display connected wallet address
24
+ - List objects owned by the connected wallet
25
+ - Clean, modern UI with Tailwind CSS
26
+
27
+ ### react-e2e-counter
28
+
29
+ A complete end-to-end example with Move smart contract integration:
30
+
31
+ - Move counter contract in `move/counter/`
32
+ - TypeScript bindings generated with `@mysten/codegen`
33
+ - Create, increment, and reset counters
34
+ - MVR (Move Registry) name resolution for package IDs
35
+ - Full transaction signing and execution
36
+
37
+ ## Tech Stack
38
+
39
+ Both templates include:
40
+
41
+ - [React](https://react.dev/) - UI framework
42
+ - [TypeScript](https://www.typescriptlang.org/) - Type safety
43
+ - [Vite](https://vitejs.dev/) - Fast build tooling
44
+ - [Tailwind CSS v4](https://tailwindcss.com/) - Utility-first styling
45
+ - [Lucide React](https://lucide.dev/) - Modern icons
46
+ - [`@mysten/dapp-kit-react`](/dapp-kit) - Wallet connection and blockchain interaction
47
+ - [pnpm](https://pnpm.io/) - Package management
48
+
49
+ The e2e-counter template also includes:
50
+
51
+ - [`@mysten/codegen`](/codegen) - Generate TypeScript from Move code
52
+
53
+ ## Project Structure
54
+
55
+ ### react-client-dapp
56
+
57
+ ```
58
+ src/
59
+ ├── components/ui/ # Reusable UI components (Card)
60
+ ├── lib/utils.ts # Utility functions
61
+ ├── App.tsx # Main application
62
+ ├── WalletStatus.tsx # Wallet connection display
63
+ ├── OwnedObjects.tsx # Object list component
64
+ ├── dApp-kit.ts # dApp Kit configuration
65
+ └── index.css # Tailwind CSS theme
66
+ ```
67
+
68
+ ### react-e2e-counter
69
+
70
+ ```
71
+ src/
72
+ ├── components/ui/ # UI components (Button, Card)
73
+ ├── contracts/ # Generated TypeScript bindings
74
+ ├── lib/utils.ts # Utility functions
75
+ ├── App.tsx # Main application
76
+ ├── Counter.tsx # Counter display and controls
77
+ ├── CreateCounter.tsx # Counter creation
78
+ ├── dApp-kit.ts # dApp Kit configuration
79
+ ├── constants.ts # Package IDs per network
80
+ └── index.css # Tailwind CSS theme
81
+ move/
82
+ └── counter/ # Move smart contract
83
+ ```
84
+
85
+ ## Using the e2e-counter Template
86
+
87
+ ### 1. Deploy the Move Contract
88
+
89
+ First, install the [Sui CLI](https://docs.sui.io/build/install) and set up testnet:
90
+
91
+ ```bash
92
+ sui client new-env --alias testnet --rpc https://fullnode.testnet.sui.io:443
93
+ sui client switch --env testnet
94
+ ```
95
+
96
+ Get testnet SUI from the [faucet](https://faucet.sui.io), then publish:
97
+
98
+ ```bash
99
+ cd move
100
+ sui client publish --gas-budget 100000000 counter
101
+ ```
102
+
103
+ ### 2. Configure the Package ID
104
+
105
+ Copy the `packageId` from the publish output to `src/constants.ts`:
106
+
107
+ ```ts
108
+
109
+ ```
110
+
111
+ ### 3. Generate TypeScript Bindings
112
+
113
+ ```bash
114
+ pnpm codegen
115
+ ```
116
+
117
+ This generates type-safe functions in `src/contracts/` for interacting with your Move modules.
118
+
119
+ ### 4. Start Development
120
+
121
+ ```bash
122
+ pnpm install
123
+ pnpm dev
124
+ ```
125
+
126
+ ## Customizing the UI
127
+
128
+ The templates use [Tailwind CSS v4](https://tailwindcss.com/docs) with
129
+ [shadcn/ui](https://ui.shadcn.com/)-style components. The UI components in `src/components/ui/` can
130
+ be customized or extended.
131
+
132
+ To add more components, copy them from the
133
+ [shadcn/ui components](https://ui.shadcn.com/docs/components) documentation and adapt them to your
134
+ project.
135
+
136
+ Theme variables are defined in `src/index.css` using Tailwind's `@theme` directive.
137
+
138
+ ## CLI Options
139
+
140
+ You can skip prompts with command-line flags:
141
+
142
+ ```bash
143
+ # Create with specific template
144
+ npm create @mysten/dapp -- -t react-e2e-counter
145
+
146
+ # Create with specific name
147
+ npm create @mysten/dapp -- -n my-app
148
+
149
+ # Create with both
150
+ npm create @mysten/dapp -- -t react-client-dapp -n my-app
151
+ ```
@@ -0,0 +1,162 @@
1
+ # Next.js
2
+
3
+ > Set up dApp Kit in a Next.js application
4
+
5
+ This guide covers integrating dApp Kit into Next.js applications, including handling server-side
6
+ rendering (SSR).
7
+
8
+ ## Installation
9
+
10
+ ```sh npm2yarn
11
+ npm i @mysten/dapp-kit-react @mysten/sui
12
+ ```
13
+
14
+ ## Setup
15
+
16
+ ### 1. Create a dApp Kit Instance
17
+
18
+ ```ts
19
+ // app/dapp-kit.ts
20
+
21
+ const GRPC_URLS = {
22
+ testnet: 'https://fullnode.testnet.sui.io:443',
23
+ } as const;
24
+
25
+ networks: ['testnet'],
26
+ createClient: (network) => new SuiGrpcClient({ network, baseUrl: GRPC_URLS[network] }),
27
+ });
28
+
29
+ // Register types for hook type inference
30
+ declare module '@mysten/dapp-kit-react' {
31
+ interface Register {
32
+ dAppKit: typeof dAppKit;
33
+ }
34
+ }
35
+ ```
36
+
37
+ ### 2. Create a Client-Only Wrapper
38
+
39
+ Wallet detection only works in the browser, so dApp Kit components must be client-side rendered:
40
+
41
+ ```tsx
42
+ // app/DAppKitClientProvider.tsx
43
+ 'use client';
44
+
45
+ return <DAppKitProvider dAppKit={dAppKit}>{children}</DAppKitProvider>;
46
+ }
47
+
48
+ ```
49
+
50
+ ### 3. Use Dynamic Import in Pages
51
+
52
+ Use Next.js dynamic imports with `ssr: false` to prevent server-side rendering:
53
+
54
+ ```tsx
55
+ // app/page.tsx
56
+
57
+ const DAppKitClientProvider = dynamic(
58
+ () => import('./DAppKitClientProvider').then((mod) => mod.DAppKitClientProvider),
59
+ { ssr: false },
60
+ );
61
+
62
+ const ConnectButton = dynamic(
63
+ () => import('./DAppKitClientProvider').then((mod) => mod.ConnectButton),
64
+ { ssr: false, loading: () => <button disabled>Loading...</button> },
65
+ );
66
+
67
+ return (
68
+ <DAppKitClientProvider>
69
+ <main>
70
+ <h1>My Sui dApp</h1>
71
+ <ConnectButton />
72
+ </main>
73
+ </DAppKitClientProvider>
74
+ );
75
+ }
76
+ ```
77
+
78
+ ## Alternative: Single Client Component
79
+
80
+ For simpler apps, create a single client component:
81
+
82
+ ```tsx
83
+ // app/WalletApp.tsx
84
+ 'use client';
85
+
86
+ function WalletStatus() {
87
+ const account = useCurrentAccount();
88
+ const dAppKit = useDAppKit();
89
+
90
+ if (!account) {
91
+ return <p>Connect your wallet to get started</p>;
92
+ }
93
+
94
+ async function handleTransfer() {
95
+ const tx = new Transaction();
96
+ tx.transferObjects([coinWithBalance({ balance: 1_000_000 })], account.address);
97
+ const result = await dAppKit.signAndExecuteTransaction({ transaction: tx });
98
+
99
+ if (result.FailedTransaction) {
100
+ throw new Error(`Transaction failed: ${result.FailedTransaction.status.error?.message}`);
101
+ }
102
+
103
+ alert(`Transaction: ${result.Transaction.digest}`);
104
+ }
105
+
106
+ return (
107
+ <div>
108
+ <p>Connected: {account.address}</p>
109
+ <button onClick={handleTransfer}>Send Transaction</button>
110
+ </div>
111
+ );
112
+ }
113
+
114
+ return (
115
+ <DAppKitProvider dAppKit={dAppKit}>
116
+ <ConnectButton />
117
+ <WalletStatus />
118
+ </DAppKitProvider>
119
+ );
120
+ }
121
+ ```
122
+
123
+ ```tsx
124
+ // app/page.tsx
125
+
126
+ const WalletApp = dynamic(() => import('./WalletApp'), {
127
+ ssr: false,
128
+ loading: () => <p>Loading wallet...</p>,
129
+ });
130
+
131
+ return (
132
+ <main>
133
+ <h1>My Sui dApp</h1>
134
+ <WalletApp />
135
+ </main>
136
+ );
137
+ }
138
+ ```
139
+
140
+ ## Key Considerations
141
+
142
+ ### Why SSR: false?
143
+
144
+ Wallets are detected via the browser's `window` object and the Wallet Standard API. This detection
145
+ cannot happen on the server, so components that interact with wallets must be client-side only.
146
+
147
+ ### Hydration Errors
148
+
149
+ If you see hydration errors, ensure all dApp Kit components are wrapped with `ssr: false` dynamic
150
+ imports or are inside a `'use client'` component that's dynamically imported.
151
+
152
+ ## Example Application
153
+
154
+ See the complete
155
+ [Next.js example](https://github.com/MystenLabs/ts-sdks/tree/main/packages/dapp-kit-next/examples/next-js/simple)
156
+ on GitHub.
157
+
158
+ ## Next Steps
159
+
160
+ - [React Hooks](/dapp-kit/react/hooks) - All available hooks
161
+ - [React Components](/dapp-kit/react/components) - UI components
162
+ - [Theming](/dapp-kit/theming) - Customize appearance