A SvelteKit starter (Svelte 5) for Cardano dApps, with a ready-made wallet connect button from @meshsdk/svelte.
src/routes/+layout.svelteimports the Mesh Svelte styles.src/routes/+page.svelterenders theCardanoWalletconnect button, shows which wallet is connected, and logs the wallet's change address using a Svelte 5$effect.
<script lang="ts">
import { CardanoWallet, BrowserWalletState } from "@meshsdk/svelte";
$effect(() => {
if (BrowserWalletState.wallet) {
BrowserWalletState.wallet.getChangeAddress().then((addr) => {
console.log(addr);
});
}
});
</script>
<CardanoWallet isDark={true} />
{#if BrowserWalletState.connected}
<p>Browser Wallet {BrowserWalletState.name} is connected!</p>
{/if}BrowserWalletState is reactive, so your components update when the user connects or disconnects a wallet.
npm install
npm run devOpen the URL Vite prints (by default http://localhost:5173). You need a Cardano browser wallet extension installed to connect.
Mesh uses WebAssembly and Node.js built-ins, so vite.config.ts adds vite-plugin-wasm, vite-plugin-top-level-await and vite-plugin-node-polyfills. Copy that file into your own SvelteKit project when adding Mesh.
- Explore the Svelte components.
- Build and submit transactions with MeshTxBuilder.
SvelteKit 2, Svelte 5, Vite 5, TypeScript, Tailwind CSS, @meshsdk/core, @meshsdk/svelte.
