A production-ready SvelteKit template for building Web3 dApps with Reown AppKit, Ethers.js, and Skeleton UI.
Clone this repository
git clone <your-repo-url>
cd template
Install dependencies
npm install
Set up environment variables
cp .env.example .env
Get your project ID from Reown Cloud and add it to .env:
VITE_PROJECT_ID=your_project_id_here
Start the development server
npm run dev
Open your browser Navigate to http://localhost:5173
src/
āāā lib/
ā āāā components/
ā ā āāā ContractInteraction.svelte # Contract interaction component
ā ā āāā ETHBalance.svelte # ETH balance display
ā ā āāā LightSwitch.svelte # Theme toggle component
ā ā āāā Navbar.svelte # Navigation with wallet connect
ā ā āāā NetworkStatus.svelte # Network status display
ā ā āāā TransactionButton.svelte # Transaction handling component
ā ā āāā WalletConnect.svelte # Enhanced wallet connect component
ā ā āāā WalletStatus.svelte # Main wallet status component
ā āāā config/
ā ā āāā appkit.ts # Reown AppKit configuration
ā ā āāā contracts.ts # Contract configurations
ā āāā stores/
ā ā āāā walletStore.ts # Wallet state management
ā ā āāā index.ts # Store exports
ā āāā utils/
ā ā āāā web3.ts # Web3 utility functions
ā āāā mint.css # Skeleton UI theme
āāā routes/
ā āāā +layout.svelte # Main layout with navbar
ā āāā +page.svelte # Homepage with wallet demo
āāā app.css # Global styles
āāā app.d.ts # TypeScript definitions
āāā app.html # HTML template
The template includes a complete wallet integration system:
import { account, network, isWalletConnected, walletActions } from '$lib/stores/walletStore';
// Check if wallet is connected
if ($isWalletConnected) {
console.log('Connected to:', $account.address);
console.log('Network:', $network.chainId);
}
// Open wallet modal
walletActions.open();
// Switch network
walletActions.switchNetwork(8453); // Base mainnet
Use Ethers.js for blockchain interactions:
import { ethers } from 'ethers';
import { walletActions } from '$lib/stores/walletStore';
async function getBalance() {
const provider = walletActions.getProvider();
if (provider) {
const ethersProvider = new ethers.BrowserProvider(provider);
const balance = await ethersProvider.getBalance(address);
return ethers.formatEther(balance);
}
}
The template includes automatic theme switching:
import { modal } from '$lib/config/appkit';
// Switch to dark mode
modal.setThemeMode('dark');
// Switch to light mode
modal.setThemeMode('light');
npm run dev - Start development servernpm run build - Build for productionnpm run preview - Preview production buildnpm run check - Run TypeScript checksnpm run lint - Run ESLint and PrettierUpdate src/lib/config/appkit.ts:
import { polygon, polygonMumbai } from '@reown/appkit/networks';
// Add to networks array
networks: [base, baseSepolia, polygon, polygonMumbai]
Modify src/lib/mint.css or create new theme files in the src/lib/ directory.
Create new components in src/lib/components/ and import them where needed.
Main wallet connection component with network status, address display, and disconnect functionality.
<WalletStatus />
Shows the current ETH balance for the connected wallet.
<ETHBalance />
Displays current network status and online/offline state.
<NetworkStatus />
Handles transaction sending with loading states and error handling.
<TransactionButton>
Send Transaction
</TransactionButton>
Generic component for interacting with smart contracts.
<ContractInteraction
contractAddress="0x..."
abi={contractABI}
functionName="transfer"
args={[recipient, amount]}
>
Transfer Tokens
</ContractInteraction>
Theme toggle component for switching between light and dark modes.
<LightSwitch />
MIT License - feel free to use this template for your projects!