frontend-apps
БесплатноБез исполняемых скриптовНе проверенBuilds Sui browser dApps with @mysten/dapp-kit-react (React, Next.js) and @mysten/dapp-kit-core (Vue, Svelte, vanilla JS, Web Components). Use when the user…
от MystenLabs★ 25 звёзд на GitHubОб этом скилле
Sui dApp Kit (frontend)
Use @mysten/dapp-kit-react (React/Next.js) or @mysten/dapp-kit-core (Vue, Svelte, vanilla, Web Components) with @mysten/sui. The bare @mysten/dapp-kit is the deprecated JSON-RPC-only package and @mysten/sui.js is the frozen v1 package — never use either in new code. Most tutorials online are v1; when unsure, fetch the docs rather than extrapolate.
Quick start (React + Vite)
npm i @mysten/dapp-kit-react @mysten/sui @tanstack/react-query
// src/dapp-kit.ts
import { createDAppKit } from '@mysten/dapp-kit-react';
import { SuiGrpcClient } from '@mysten/sui/grpc';
const GRPC_URLS = {
testnet: 'https://fullnode.testnet.sui.io',
mainnet: 'https://fullnode.mainnet.sui.io',
} as const;
export const dAppKit = createDAppKit({
networks: ['testnet', 'mainnet'],
defaultNetwork: 'testnet',
createClient: (network) => new SuiGrpcClient({ network, url: GRPC_URLS[network] }),
});
// React only: gives every hook the right types without passing the instance around.
declare module '@mysten/dapp-kit-react' {
interface Register {
dAppKit: typeof dAppKit;
}
}
// src/main.tsx
import { DAppKitProvider } from '@mysten/dapp-kit-react';
import '@mysten/dapp-kit-react/ui/styles.css';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { dAppKit } from './dapp-kit';
const queryClient = new QueryClient();
createRoot(document.getElementById('root')!).render(
<QueryClientProvider client={queryClient}>
<DAppKitProvider dAppKit={dAppKit}>
<App />
</DAppKitProvider>
</QueryClientProvider>,
);
QueryClientProvider is only for your own TanStack queries; dApp Kit itself no longer needs it. There is no SuiClientProvider or WalletProvider anymore.
Connect UI: import { ConnectButton } from '@mysten/dapp-kit-react/ui' — importing it from the package root silently renders nothing.
Current hooks: useCurrentAccount, useCurrentWallet, useCurrentNetwork, useCurrentClient, useDAppKit, useWallets, useWalletConnection.
Removed hooks (treat any occurrence as a bug): useSuiClientQuery, useSuiClientInfiniteQuery, useSuiClientContext, useSuiClient, useSignAndExecuteTransaction, useConnectWallet, useDisconnectWallet.
Reading on-chain data
Always read through useCurrentClient() + TanStack Query. Never construct a client inside a component (breaks network switching). Gate on the account.
import { useCurrentAccount, useCurrentClient, useCurrentNetwork } from '@mysten/dapp-kit-react';
import { useQuery } from '@tanstack/react-query';
export function Balance() {
const account = useCurrentAccount();
const client = useCurrentClient();
const network = useCurrentNetwork();
const { data, isPending, error } = useQuery({
queryKey: ['balances', network, account?.address],
queryFn: () => client.core.listBalances({ owner: account!.address }),
enabled: !!account, // useCurrentAccount() is null until a wallet connects
});
if (!account) return <p>Connect a wallet.</p>;
if (isPending) return <p>Loading…</p>;
if (error) return <p>{error.message}</p>;
// pick the entry whose coinType is 0x2::sui::SUI
return <pre>{JSON.stringify(data, null, 2)}</pre>;
}
Pagination uses useInfiniteQuery and the v2 single nullable cursor (there is no nextCursor / hasNextPage on the response):
const q = useInfiniteQuery({
queryKey: ['nfts', network, account?.address],
queryFn: ({ pageParam }) =>
client.core.listOwnedObjects({
owner: account!.address,
type: '0xPKG::nft::NFT',
cursor: pageParam,
}),
initialPageParam: null as string | null,
getNextPageParam: (lastPage) => lastPage.cursor ?? undefined,
enabled: !!account,
});
const nfts = q.data?.pages.flatMap((page) => page.objects) ?? [];
<button onClick={() => q.fetchNextPage()} disabled={!q.hasNextPage || q.isFetchingNextPage}>
{q.isFetchingNextPage ? 'Loading…' : 'Load more'}
</button>
Sending a transaction
Checklist — follow in this order, the ordering is what breaks:
- Build a
Transactionwith typed pure helpers (tx.pure.u64,tx.pure.address,tx.pure.string). Nevertx.pure(v). - Do not call
tx.build(),setGasBudget,setGasPriceorsetGasPayment— the wallet selects gas and dry-runs for budget. const result = await useDAppKit().signAndExecuteTransaction({ transaction: tx })— imperatively, in the event handler. The parameter istransaction, nottransactionBlock.- Check
result.$kind === 'FailedTransaction'(orresult.FailedTransaction) before reading anything. Success digest lives atresult.Transaction.digest. await client.waitForTransaction({ digest })— fullnodes index asynchronously.- Then
queryClient.invalidateQueries(...). Invalidating first refetches stale data.
import { useCurrentClient, useDAppKit } from '@mysten/dapp-kit-react';
import { useQueryClient } from '@tanstack/react-query';
impor
Установить frontend-apps в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл frontend-apps?
Builds Sui browser dApps with @mysten/dapp-kit-react (React, Next.js) and @mysten/dapp-kit-core (Vue, Svelte, vanilla JS, Web Components). Use when the user asks how to connect a Sui wallet, add a ConnectButton, set up createDAppKit or DAppKitProvider, read a balance or owned objects/NFTs in a frontend, sign and execute a transaction from a React or Vue component, sponsor gas from a backend, fix a UI that is stale after a transaction, handle Next.js App Router 'use client' / SSR for Sui, migrate off the deprecated @mysten/dapp-kit package or removed hooks (useSuiClientQuery, useSuiClient, useSignAndExecuteTransaction, useConnectWallet), or review Sui frontend code. Pair with the `sui-sdks` skill for @mysten/sui Transaction construction and the `ptbs` skill for PTB semantics.
Как установить скилл frontend-apps?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл frontend-apps запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic