Aptos dApp Development Guide
This comprehensive guide covers building modern decentralized applications (dApps) on the Aptos blockchain using the latest @aptos-labs/ts-sdk and development best practices for 2025.
Prerequisites
- Node.js 18+ for running the development environment
- Basic TypeScript/JavaScript knowledge for frontend development
- Understanding of React for UI components (optional but recommended)
- Aptos wallet installed (Petra, Pontem, or other Aptos-compatible wallets)
Core Technologies
Essential Packages
# Core Aptos SDK
npm install @aptos-labs/ts-sdk
# React integration (optional)
npm install react react-dom @types/react @types/react-dom
# State management
npm install @tanstack/react-query
# UI components (optional)
npm install @aptos-labs/wallet-adapter-react
Package Overview
- @aptos-labs/ts-sdk: Core SDK for blockchain interactions
- @aptos-labs/wallet-adapter-react: React hooks for wallet integration
- @tanstack/react-query: State management for async data
Basic Setup
1. Initialize Aptos Client
import { Aptos, AptosConfig, Network } from '@aptos-labs/ts-sdk';
// Initialize for different networks
const config = new AptosConfig({
network: Network.MAINNET // Network.TESTNET, Network.DEVNET
});
const aptos = new Aptos(config);
// Using BlockEden.xyz endpoint
const blockEdenConfig = new AptosConfig({
fullnode: 'https://aptos-mainnet.blockeden.xyz/<access_key>',
network: Network.MAINNET,
});
const blockEdenAptos = new Aptos(blockEdenConfig);
2. React dApp Setup with Wallet Integration
// App.tsx
import React from 'react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { WalletProvider } from '@aptos-labs/wallet-adapter-react';
import { PetraWallet } from 'petra-plugin-wallet-adapter';
import { PontemWallet } from '@pontem/wallet-adapter-plugin';
const queryClient = new QueryClient();
const wallets = [
new PetraWallet(),
new PontemWallet(),
];
function App() {
return (
<QueryClientProvider client={queryClient}>
<WalletProvider wallets={wallets} autoConnect={true}>
<MyDApp />
</WalletProvider>
</QueryClientProvider>
);
}
export default App;