Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

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от 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:

  1. Build a Transaction with typed pure helpers (tx.pure.u64, tx.pure.address, tx.pure.string). Never tx.pure(v).
  2. Do not call tx.build(), setGasBudget, setGasPrice or setGasPayment — the wallet selects gas and dry-runs for budget.
  3. const result = await useDAppKit().signAndExecuteTransaction({ transaction: tx }) — imperatively, in the event handler. The parameter is transaction, not transactionBlock.
  4. Check result.$kind === 'FailedTransaction' (or result.FailedTransaction) before reading anything. Success digest lives at result.Transaction.digest.
  5. await client.waitForTransaction({ digest }) — fullnodes index asynchronously.
  6. Then queryClient.invalidateQueries(...). Invalidating first refetches stale data.
import { useCurrentClient, useDAppKit } from '@mysten/dapp-kit-react';
import { useQueryClient } from '@tanstack/react-query';
impor
Полный SKILL.md на GitHub

Установить frontend-apps в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

evals/code-evals.jsonevals/evals.jsonlimitations.mdnon-react.mdqueries.mdreact.mdsetup.mdtransactions.md

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), без исполняемых скриптов.

Похожие скиллы

Сравнить frontend-apps с