Skip to content
Chapters

Getting started

Starting the project

The official scaffold, the templates, and the thing most teams lose: the program keypair.

npm create solana-dapp@latest   # pick an *-anchor template
cd my-project
npm install
npm run anchor build     # compiles the program
npm run anchor test      # tests it against a local validator (Surfpool on Anchor 1.x)
npm run dev              # starts the frontend

You get a monorepo with anchor/ (example program, tests, Anchor.toml) and a frontend with the wallet and client already wired up. The scripts depend on the template: read package.json before assuming npm run anchor ….

The program ID is a keypair. It lives in target/deploy/<program>-keypair.json: do not commit it, share it with the team over a private channel, and after cloning run anchor keys sync so declare_id! and Anchor.toml point at the same address. Lose it and the program changes address — and with it the frontend, the IDL and everything you already deployed.

Official templates (solana.com/developers/templates), in case you want to start from somewhere else:

Template Stack
nextjs / nextjs-anchor Next.js + @solana/kit (+ a vault program in Anchor)
react-vite / react-vite-anchor Vite + React + @solana/kit
phantom-embedded-react Next.js + Phantom embedded wallet
web3js-expo / phantom-embedded-react-native-starter Mobile (Expo)
x402-template Next.js with pay-per-request (x402)
pinocchio-counter Native program without Anchor
supabase-auth Traditional auth + Solana

And the reference repo: solana-developers/program-examples — implementations of nearly every pattern (counter, escrow, tokens, PDAs, CPI).