0.14.28 • Published 16 days ago

@mysten/dapp-kit v0.14.28

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
16 days ago

Sui dApp Kit

The Sui dApp Kit is a set of React components, hooks, and utilities that make it easy to build a dApp for the Sui ecosystem. It provides hooks and components for querying data from the Sui blockchain, and connecting to Sui wallets.

See https://sdk.mystenlabs.com/typescript for full documentation

Core Features

  • Query Hooks: dApp Kit provides a set of hooks for making rpc calls to the Sui blockchain, making it easy to load any information needed for your dApp.
  • Automatic Wallet State Management: dApp Kit removes the complexity of state management related to wallet connections. You can focus on building your dApp.
  • Supports all Sui wallets: No need to manually define wallets you support. All Sui wallets are automatically supported.
  • Easy to integrate: dApp Kit provides pre-built React Components that you can drop right into your dApp, for easier integration
  • Flexible: dApp Kit ships both fully functional React Component, and lower level hooks that you can use to build your own custom components.

Install from NPM

To use the Sui dApp Kit in your project, run the following command in your project root:

npm i --save @mysten/dapp-kit @mysten/sui @tanstack/react-query

Setting up providers

To be able to use the hooks and components in the dApp Kit, you need to wrap your app with a couple providers. The props available on the providers are covered in more detail in their respective docs pages.

import { createNetworkConfig, SuiClientProvider, WalletProvider } from '@mysten/dapp-kit';
import { getFullnodeUrl, type SuiClientOptions } from '@mysten/sui/client';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';

// Config options for the networks you want to connect to
const { networkConfig } = createNetworkConfig({
	localnet: { url: getFullnodeUrl('localnet') },
	mainnet: { url: getFullnodeUrl('mainnet') },
});
const queryClient = new QueryClient();

function App() {
	return (
		<QueryClientProvider client={queryClient}>
			<SuiClientProvider networks={networkConfig} defaultNetwork="localnet">
				<WalletProvider>
					<YourApp />
				</WalletProvider>
			</SuiClientProvider>
		</QueryClientProvider>
	);
}

Using UI components to connect to a wallet

The dApp Kit provides a set of flexible UI components that can be used to connect and manage wallet accounts from your dApp. The components are built on top of Radix UI and are customizable so you can quickly get your dApp up and running.

To use our provided UI components, you will need to import the dApp Kit's CSS stylesheet into your dApp as shown below. For more information regarding customization options, check out the respective documentation pages for the components and themes.

import '@mysten/dapp-kit/dist/index.css';

Using hooks to make RPC calls

The dApp Kit provides a set of hooks for making RPC calls to the Sui blockchain. The hooks are thin wrappers around useQuery from @tanstack/react-query. For more comprehensive documentation on how these query hooks can be used, check out the react-query docs.

import { useSuiClientQuery } from '@mysten/dapp-kit';

function MyComponent() {
	const { data, isPending, error, refetch } = useSuiClientQuery('getOwnedObjects', {
		owner: '0x123',
	});

	if (isPending) {
		return <div>Loading...</div>;
	}

	return <pre>{JSON.stringify(data, null, 2)}</pre>;
}
0.14.28

16 days ago

0.14.27

30 days ago

0.14.26

1 month ago

0.14.24

2 months ago

0.14.23

2 months ago

0.14.22

2 months ago

0.14.25

1 month ago

0.14.21

2 months ago

0.14.20

2 months ago

0.14.19

2 months ago

0.14.18

2 months ago

0.14.13

4 months ago

0.14.12

4 months ago

0.14.11

5 months ago

0.14.10

5 months ago

0.14.17

3 months ago

0.14.16

3 months ago

0.14.15

3 months ago

0.14.14

4 months ago

0.14.5

6 months ago

0.14.6

5 months ago

0.14.7

5 months ago

0.14.8

5 months ago

0.14.9

5 months ago

0.14.0

6 months ago

0.14.1

6 months ago

0.14.2

6 months ago

0.14.3

6 months ago

0.14.4

6 months ago

0.13.2

6 months ago

0.13.1

6 months ago

0.13.0

6 months ago

0.12.15

6 months ago

0.12.14

6 months ago

0.12.13

6 months ago

0.12.11

7 months ago

0.12.12

7 months ago

0.12.10

7 months ago

0.12.8

8 months ago

0.12.9

8 months ago

0.12.7

8 months ago

0.12.6

8 months ago

0.12.3

8 months ago

0.12.4

8 months ago

0.12.5

8 months ago

0.12.2

9 months ago

0.12.0

9 months ago

0.12.1

9 months ago

0.11.0

11 months ago

0.11.1

11 months ago

0.10.3

11 months ago

0.10.2

12 months ago

0.10.1

12 months ago

0.10.0

12 months ago

0.9.1

12 months ago

0.9.0

1 year ago

0.8.0

1 year ago

0.7.0

1 year ago

0.6.0

1 year ago

0.5.0

1 year ago

0.4.0

1 year ago

0.3.0

1 year ago

0.2.4

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago