A SolidJS 2 implementation of the Sui dApp kit, providing wallet connection and management utilities for building decentralized applications on the SUI blockchain. This library closely mirrors the structure and API of the official @mysten/dapp-kit-react package but is purpose-built for SolidJS developers.
pnpm add @algonet/sui-dappkit-solidThis library requires the following peer dependencies:
| Package | Version |
|---|---|
| @mysten/sui | ^2.0.0 |
| solid-js | ^2.0.0 |
| tailwindcss | ^4.0.0 |
import { createDAppKit } from "@algonet/sui-dapp-kit-solid";
import { SuiGrpcClient } from "@mysten/sui/grpc";
const network = 'testnet';
export const grpcClient = new SuiGrpcClient({
network,
baseUrl: "https://fullnode.testnet.sui.io:443",
});
const dAppKit = createDAppKit({
networks: [network],
createClient: () => grpcClient,
autoConnect: true,
defaultNetwork: network
});import { DAppKitProvider } from "@algonet/sui-dappkit-solid";
function App() {
return (
<DAppKitProvider dAppKit={dAppKit}>
<YourComponents />
</DAppKitProvider>
);
}Import the pre-built UI components from the ui entry point:
import { ConnectButton, ConnectModal } from "@algonet/sui-dappkit-solid/ui";
function YourUI() {
return (
<>
<ConnectButton />
<ConnectModal />
</>
);
}import { useCurrentAccount, useWalletConnection } from "@algonet/sui-dappkit-solid";
function AccountDisplay() {
const account = useCurrentAccount();
const connection = useWalletConnection();
return (
<div>
{account()?.address ?? "Not connected"}
{/* Or access other properties like .wallet, .discoveredWallets */}
</div>
);
}The context provider that supplies the DAppKit instance throughout your SolidJS component tree.
| Prop | Type | Required | Description |
|---|---|---|---|
dAppKit |
DefaultExpectedDppKit |
β Yes | The DAppKit instance created via createDAppKit |
children |
ParentProps |
β Yes | Child components that will have access to the DAppKit context |
type DAppKitProviderProps = ParentProps<{
dAppKit: DefaultExpectedDppKit;
}>;A pre-built button component that toggles wallet connection. Renders as a custom element <mysten-dapp-kit-connect-button>. The underlying DOM element is defined by the core package.
| Prop | Type | Required | Description |
|---|---|---|---|
dAppKit |
DAppKit<[], DAppKitCompatibleClient> |
β No | Optional override of the instance from context |
type ConnectButtonProps = {
dAppKit?: DAppKit<[], DAppKitCompatibleClient>;
};A pre-built modal component for wallet discovery and connection. Renders as a custom element <mysten-dapp-kit-connect-modal>.
| Prop | Type | Required | Description |
|---|---|---|---|
dAppKit |
DAppKit<[], DAppKitCompatibleClient> |
β No | Optional override of the instance from context |
type ConnectModalProps = {
dAppKit?: DAppKit<[], DAppKitCompatibleClient>;
};All hooks can optionally accept a dAppKit parameter to override the instance from context. They return SolidJS signals that reactively update when wallet state changes.
Returns the active DAppKit instance. Must be called within a DAppKitProvider.
function useDAppKit<TDAppKit>(dAppKit?: TDAppKit): TDAppKit;Returns a signal for the currently connected account address, or null if not connected.
type UseCurrentAccountOptions<TDAppKit> = {
dAppKit?: TDAppKit;
};
function useCurrentAccount(options?: UseCurrentAccountOptions<TDAppKit>): () => Account | null;Returns a signal for the currently connected wallet.
type UseCurrentWalletOptions<TDAppKit> = {
dAppKit?: TDAppKit;
};
function useCurrentWallet(options?: UseCurrentWalletOptions<TDAppKit>): () => WalletInfo | null;Returns a signal for the current RPC client instance.
type UseCurrentClientOptions<TDAppKit> = {
dAppKit?: TDAppKit;
};
function useCurrentClient(options?: UseCurrentClientOptions<TDAppKit>): () => SuiClient | undefined;Returns a signal for the current network.
type UseCurrentNetworkOptions<TDAppKit> = {
dAppKit?: TDAppKit;
};
function useCurrentNetwork(options?: UseCurrentNetworkOptions<TDAppKit>): () => Network | undefined;Returns a signal for the full wallet connection state (account, wallet, discovered wallets, etc.).
type UseWalletConnectionOptions<TDAppKit> = {
dAppKit?: TDAppKit;
};
function useWalletConnection(options?: UseWalletConnectionOptions<TDAppKit>): () => Connection | null;Returns a signal for the list of discovered wallets.
type UseWalletOptions<TDAppKit> = {
dAppKit?: TDAppKit;
};
function useWallets(options?: UseWalletOptions<TDAppKit>): () => readonly UiWallet[];Internal hook to access the DAppKit context directly. Useful when you need low-level access to the provider's context value.
function useDappKitContext(): DefaultExpectedDppKit | undefined;This library re-exports everything from @mysten/dapp-kit-core as a convenience:
export * from "@mysten/dapp-kit-core";See the dApp Kit Core docs for all core types and utilities.
sui-dappkit-solid/
βββ src/
β βββ components/
β β βββ ConnectButton/ # Pre-built connect button component
β β βββ ConnectModal/ # Pre-built connect modal component
β β βββ DAppKitProvider/ # Context provider & hook
β βββ hooks/
β β βββ useCurrentAccount/ # Current account signal
β β βββ useCurrentClient/ # Current RPC client signal
β β βββ useCurrentNetwork/ # Current network signal
β β βββ useCurrentWallet/ # Current wallet info signal
β β βββ useDAppKit/ # DAppKit instance retrieval
β β βββ useWalletConnection/ # Connection state signal
β β βββ useWallets/ # Discovered wallets list signal
β βββ index.ts # Main entry point (hooks + components)
β βββ ui.ts # UI entries point (ConnectButton, ConnectModal, CSS)
β βββ ui.css # Tailwind-based default styles
β βββ global.d.ts # Type declarations
βββ package.json
βββ tsconfig.json # TypeScript config (ES2022, strict)
βββ vite.config.ts # Vite lib build with Solid plugin + dts
βββ vitest.config.ts # Vitest test configuration
βββ biome.json # Biome formatter / linter config
βββ README.md
git clone https://github.com/Algo-Net/Sui-dAppKit-Solid.git
cd sui-dappkit-solid
pnpm install| Script | Description |
|---|---|
pnpm build |
Build the library with Vite (ESM) + TypeScript declarations |
pnpm test |
Run the test suite with Vitest |
pnpm lint |
Lint and format with Biome |
The library is built with Vite in library mode, producing:
dist/index.jsβ Main entry (hooks + components)dist/ui.jsβ UI components entrydist/sui-dapp-kit-solid.cssβ Default stylesheet- TypeScript declaration files (
.d.ts) alongside each entry
pnpm buildpnpm testTests are written with Vitest and render hooks/components using @solidjs/testing-library.
This project uses Biome for linting and formatting:
- Line width: 120 characters
- Indentation: 4 spaces
- Quotes: Double
- Includes import organization on save via assist actions
# Lint and auto-fix
pnpm lint- Target: ES2022
- Module resolution: Bundler strategy (
"bundler") - Strict mode: Enabled
- JSX: Preserved (handled by the Solid compiler)
jsxImportSource:@solidjs/web
The scope of this project is to provide a SolidJS equivalent to the react implementation. Any additions, improvements or fixes that fall within this scope are welcome.
Please feel free to submit issues and pull requests.