create-solana-dapp
Scaffold a full-stack Solana dApp with an on-chain program and Next.js client using the create-solana-dapp generator.
Recipe
Quick-reference recipe card - copy-paste ready.
pnpm create solana-dapp@latest
cd my-dapp
pnpm install
anchor build
pnpm devWhen to reach for this:
- Greenfield product needing wallet-connected UI plus program.
- Standardizing repo layout across multiple Solana apps.
- Teaching the program + client split with working defaults.
- Skipping manual Next.js + Anchor wiring.
Working Example
pnpm create solana-dapp@latest my-marketplace \
--template anchor-nextjs \
--wallet adapter
cd my-marketplace
pnpm install
# Align toolchain with guide pins
avm use 0.32.1
anchor build
anchor test
# Start local validator + app (template scripts vary)
pnpm devWhat this demonstrates:
- Monorepo or workspace layout with
programs/andapp/folders. - Pre-wired wallet adapter and RPC configuration hooks.
- Anchor 0.32.1 program stub ready for
anchor build.
Deep Dive
How It Works
- Generator copies a template with Anchor program, tests, and Next.js frontend.
- Client uses modern wallet standards (wallet-adapter or template-specific kit).
- Scripts wrap
solana-test-validator, deploy, and dev server startup. - You replace stub instructions with product logic incrementally.
Typical Layout
| Path | Contents |
|---|---|
programs/<name>/ | Anchor program source |
app/ or src/ | Next.js frontend |
Anchor.toml | Program IDs and cluster URLs |
tests/ | Integration tests |
bash Notes
# Re-run codegen after IDL changes (template-dependent)
anchor build
pnpm run codegen 2>/dev/null || trueGotchas
- Stale template Anchor version - generator default may lag 0.32.1. Fix: bump
Anchor.toml,anchor-lang, and runavm use 0.32.1. - Assuming devnet config - template may point at localnet. Fix: read README and set
Anchor.tomlprovider cluster. - Skipping validator startup - client txs fail without RPC. Fix: run bundled validator script or Surfpool.
- Committing program keypairs - templates include deploy keys for convenience. Fix: rotate for production; gitignore secrets.
- Heavy template features - unused UI dependencies slow installs. Fix: prune packages after scaffold if minimal API-only client needed.
Alternatives
| Alternative | Use When | Don't Use When |
|---|---|---|
anchor init only | Program-first, client later | Need immediate UI |
mucho CLI | Foundation opinionated templates | Custom Next.js architecture |
| Manual monorepo | Full control of stack choices | Fast MVP deadline |
create-solana-dapp minimal flags | Slimmer output | Learning full-stack wiring |
FAQs
Does it pin @solana/kit 7.0.0?
Check generated package.json and bump to 7.0.0 to match this guide's pinned stack.
Can I use npm instead of pnpm?
Templates often document pnpm first; npm/yarn usually work with equivalent install commands.
Where is the program ID set?
Anchor.toml and declare_id! in programs/<name>/src/lib.rs - update after anchor keys sync.
How do I deploy from the scaffold?
anchor deploy against configured cluster after funding deployer keypair.
Can I remove Next.js?
Yes - keep programs/ and tests; replace frontend with any kit-based client.
Does scaffold include tests?
Most templates include Anchor integration tests - extend with LiteSVM for unit speed.
How do I add Tailwind or UI kit?
Select template variants at create time or add dependencies post-generation.
Is create-solana-dapp official?
Community-maintained scaffold widely used in Solana ecosystem tutorials - verify template repo for updates.
How do I configure devnet?
Edit Anchor.toml provider URL and frontend env NEXT_PUBLIC_RPC_URL.
What wallet adapters are included?
Depends on template flag - commonly @solana/wallet-adapter-react or kit-native wallets.
Related
- Toolchain Overview - required tools
- Mucho CLI - alternative scaffold path
- solana-test-validator - local RPC
- Anchor Basics - program structure
Stack 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.