dApp Integration Basics
9 examples for structuring a Solana Next.js App Router dApp - 6 basic and 3 intermediate.
Search across all documentation pages
9 examples for structuring a Solana Next.js App Router dApp - 6 basic and 3 intermediate.
npx create-solana-dapp@latest my-dapp
# or: npx create-next-app@latest && npm install @solana/kit@7.0.0Use App Router (app/ directory). Wallet providers live in a client layout wrapper.
app/
layout.tsx # root
solana-provider.tsx # "use client" providers
page.tsx # marketing (server OK)
dashboard/
page.tsx # client-heavy UIapp/api/ for server-built txs.NEXT_PUBLIC_RPC_URL=https://api.devnet.solana.com
NEXT_PUBLIC_CLUSTER=devnet
# Server-only:
# SPONSOR_KEYPAIR_PATH=...NEXT_PUBLIC_ values ship to browser - never secrets.// app/solana-provider.tsx
"use client";
export function SolanaProvider({ children }: { children: React.ReactNode }) {
return <WalletProviders>{children}</WalletProviders>;
}// Server Component: createSolanaRpc reads
// Client Component: wallet signs and sends"use client";
import { useWallet } from "@solana/wallet-adapter-react";// app/dashboard/error.tsx and loading.tsx// app/api/tx/route.ts - server builds partial tx"use client";
// useSWR + accountSubscribe for live balance// pending → confirmed → explorer linkStack versions: This page was written for Agave 4.1.1, Solana CLI 3.0.10, Anchor 0.32.1, anchor-lang 0.32.1, Rust 1.91.1, @solana/kit 7.0.0, Surfpool 0.12.0, and LiteSVM 0.6.x.
Reviewed by Chris St. John·Last updated Jul 16, 2026