|
| 1 | +# create-base-app |
| 2 | + |
| 3 | +Create Base applications with Sign in with Base and Base Pay preconfigured in seconds. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +✨ **Quick Setup** - Get a fully configured Base app running in under a minute |
| 8 | +🔐 **Sign in with Base** - Authentication with Base accounts built-in |
| 9 | +💳 **Base Pay** - Accept USDC payments on Base out of the box |
| 10 | +🎨 **Multiple Frameworks** - Support for React, Next.js, Vue, and Svelte |
| 11 | +📦 **TypeScript Support** - Optional TypeScript configuration |
| 12 | +🚀 **Production Ready** - Best practices and optimized build configuration |
| 13 | + |
| 14 | +## Quick Start |
| 15 | + |
| 16 | +### Using npx (recommended) |
| 17 | + |
| 18 | +```bash |
| 19 | +npx create-base-app my-app |
| 20 | +cd my-app |
| 21 | +npm run dev |
| 22 | +``` |
| 23 | + |
| 24 | +### Using npm |
| 25 | + |
| 26 | +```bash |
| 27 | +npm create base-app my-app |
| 28 | +cd my-app |
| 29 | +npm run dev |
| 30 | +``` |
| 31 | + |
| 32 | +### Using yarn |
| 33 | + |
| 34 | +```bash |
| 35 | +yarn create base-app my-app |
| 36 | +cd my-app |
| 37 | +yarn dev |
| 38 | +``` |
| 39 | + |
| 40 | +### Using pnpm |
| 41 | + |
| 42 | +```bash |
| 43 | +pnpm create base-app my-app |
| 44 | +cd my-app |
| 45 | +pnpm dev |
| 46 | +``` |
| 47 | + |
| 48 | +## Options |
| 49 | + |
| 50 | +You can pass options directly to skip the interactive prompts: |
| 51 | + |
| 52 | +```bash |
| 53 | +npx create-base-app my-app \ |
| 54 | + --framework nextjs \ |
| 55 | + --typescript \ |
| 56 | + --package-manager yarn |
| 57 | +``` |
| 58 | + |
| 59 | +### Available Options |
| 60 | + |
| 61 | +- `--framework <framework>` - Choose framework: `react`, `nextjs`, `vue`, or `svelte` |
| 62 | +- `--typescript` / `--no-typescript` - Use TypeScript (default: true) |
| 63 | +- `--package-manager <pm>` - Package manager: `npm`, `yarn`, or `pnpm` |
| 64 | +- `--no-git` - Skip git initialization |
| 65 | +- `--no-install` - Skip dependency installation |
| 66 | + |
| 67 | +## What's Included |
| 68 | + |
| 69 | +Each generated project includes: |
| 70 | + |
| 71 | +### 🔐 Sign in with Base |
| 72 | +- Pre-configured authentication flow |
| 73 | +- Wallet connection handling |
| 74 | +- Session management |
| 75 | +- Server-side signature verification (Next.js) |
| 76 | + |
| 77 | +### 💳 Base Pay |
| 78 | +- Payment UI components |
| 79 | +- USDC payment processing |
| 80 | +- Transaction status tracking |
| 81 | +- Testnet support for development |
| 82 | + |
| 83 | +### 🎨 Modern UI |
| 84 | +- Responsive design |
| 85 | +- Light/dark mode support |
| 86 | +- Accessible components |
| 87 | +- Mobile-optimized |
| 88 | + |
| 89 | +### 🛠 Developer Experience |
| 90 | +- Hot module replacement |
| 91 | +- TypeScript support (optional) |
| 92 | +- ESLint configuration |
| 93 | +- Production build optimization |
| 94 | + |
| 95 | +## Project Structure |
| 96 | + |
| 97 | +``` |
| 98 | +my-base-app/ |
| 99 | +├── src/ |
| 100 | +│ ├── components/ |
| 101 | +│ │ ├── AuthComponent # Sign in with Base |
| 102 | +│ │ └── PaymentComponent # Base Pay integration |
| 103 | +│ ├── providers/ |
| 104 | +│ │ └── BaseProvider # SDK initialization |
| 105 | +│ └── App # Main application |
| 106 | +├── .env.example # Environment variables |
| 107 | +├── package.json |
| 108 | +└── README.md |
| 109 | +``` |
| 110 | + |
| 111 | +## Configuration |
| 112 | + |
| 113 | +### Environment Variables |
| 114 | + |
| 115 | +Each project includes a `.env.example` file with the following variables: |
| 116 | + |
| 117 | +```env |
| 118 | +# Base Account SDK Configuration |
| 119 | +NEXT_PUBLIC_APP_NAME=my-base-app |
| 120 | +NEXT_PUBLIC_APP_CHAIN_IDS=8453,84532 # Base mainnet, Base Sepolia |
| 121 | +NEXT_PUBLIC_WALLET_URL=https://wallet.coinbase.com |
| 122 | +``` |
| 123 | + |
| 124 | +### Supported Chains |
| 125 | + |
| 126 | +- **Base Mainnet** (Chain ID: 8453) - Production |
| 127 | +- **Base Sepolia** (Chain ID: 84532) - Testing |
| 128 | + |
| 129 | +## Testing |
| 130 | + |
| 131 | +### Get Test Funds |
| 132 | + |
| 133 | +1. Visit [Circle Faucet](https://faucet.circle.com/) |
| 134 | +2. Select "Base Sepolia" network |
| 135 | +3. Request test ETH and USDC |
| 136 | +4. Use `testnet: true` in payment calls |
| 137 | + |
| 138 | +### Test Payment Flow |
| 139 | + |
| 140 | +1. Connect your wallet |
| 141 | +2. Ensure you're on Base Sepolia network |
| 142 | +3. Enter payment amount (minimum 0.01 USDC) |
| 143 | +4. Confirm transaction in your wallet |
| 144 | +5. View transaction status |
| 145 | + |
| 146 | +## Framework Templates |
| 147 | + |
| 148 | +### React |
| 149 | +- Vite for fast development |
| 150 | +- React 18 with hooks |
| 151 | +- CSS modules |
| 152 | + |
| 153 | +### Next.js |
| 154 | +- App or Pages router |
| 155 | +- API routes for auth |
| 156 | +- Server-side rendering |
| 157 | +- Optimized production builds |
| 158 | + |
| 159 | +### Vue (Coming Soon) |
| 160 | +- Vue 3 composition API |
| 161 | +- Vite build system |
| 162 | +- Vue Router integration |
| 163 | + |
| 164 | +### Svelte (Coming Soon) |
| 165 | +- SvelteKit framework |
| 166 | +- Server-side rendering |
| 167 | +- Built-in routing |
| 168 | + |
| 169 | +## API Reference |
| 170 | + |
| 171 | +### Authentication |
| 172 | + |
| 173 | +```javascript |
| 174 | +// Sign in with Base |
| 175 | +const provider = sdk.getProvider(); |
| 176 | +const accounts = await provider.request({ |
| 177 | + method: 'eth_requestAccounts' |
| 178 | +}); |
| 179 | + |
| 180 | +// Sign message for verification |
| 181 | +const signature = await provider.request({ |
| 182 | + method: 'personal_sign', |
| 183 | + params: [message, address], |
| 184 | +}); |
| 185 | +``` |
| 186 | + |
| 187 | +### Payments |
| 188 | + |
| 189 | +```javascript |
| 190 | +// Process payment |
| 191 | +const result = await base.pay({ |
| 192 | + amount: '1.00', // Amount in USDC |
| 193 | + to: '0x...', // Recipient address |
| 194 | + testnet: true, // Use testnet |
| 195 | +}); |
| 196 | + |
| 197 | +// Check payment status |
| 198 | +const status = await base.getPaymentStatus({ |
| 199 | + id: result.id, |
| 200 | + testnet: true |
| 201 | +}); |
| 202 | +``` |
| 203 | + |
| 204 | +## Deployment |
| 205 | + |
| 206 | +### Vercel |
| 207 | + |
| 208 | +```bash |
| 209 | +npm run build |
| 210 | +vercel deploy |
| 211 | +``` |
| 212 | + |
| 213 | +### Netlify |
| 214 | + |
| 215 | +```bash |
| 216 | +npm run build |
| 217 | +netlify deploy --dir=dist |
| 218 | +``` |
| 219 | + |
| 220 | +### Docker |
| 221 | + |
| 222 | +```dockerfile |
| 223 | +FROM node:18-alpine |
| 224 | +WORKDIR /app |
| 225 | +COPY package*.json ./ |
| 226 | +RUN npm ci |
| 227 | +COPY . . |
| 228 | +RUN npm run build |
| 229 | +EXPOSE 3000 |
| 230 | +CMD ["npm", "start"] |
| 231 | +``` |
| 232 | + |
| 233 | +## Troubleshooting |
| 234 | + |
| 235 | +### Common Issues |
| 236 | + |
| 237 | +**Wallet not connecting** |
| 238 | +- Ensure you have a Base-compatible wallet installed |
| 239 | +- Check that you're on the correct network |
| 240 | +- Clear browser cache and reconnect |
| 241 | + |
| 242 | +**Payment failing** |
| 243 | +- Verify sufficient balance (ETH for gas, USDC for payment) |
| 244 | +- Check recipient address is valid |
| 245 | +- Ensure correct network (mainnet vs testnet) |
| 246 | + |
| 247 | +**Build errors** |
| 248 | +- Clear node_modules and reinstall |
| 249 | +- Check Node.js version (18+ required) |
| 250 | +- Verify all environment variables are set |
| 251 | + |
| 252 | +## Resources |
| 253 | + |
| 254 | +- [Base Documentation](https://docs.base.org) |
| 255 | +- [Base Account SDK](https://github.com/base/account-sdk) |
| 256 | +- [Base Pay Guide](https://docs.base.org/building-with-base/products/base-pay) |
| 257 | +- [Sign in with Base](https://docs.base.org/building-with-base/products/sign-in-with-base) |
| 258 | +- [Discord Community](https://discord.gg/base) |
| 259 | + |
| 260 | +## Contributing |
| 261 | + |
| 262 | +We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for details. |
| 263 | + |
| 264 | +### Development |
| 265 | + |
| 266 | +```bash |
| 267 | +# Clone the repo |
| 268 | +git clone https://github.com/base/account-sdk.git |
| 269 | +cd account-sdk/packages/create-base-app |
| 270 | + |
| 271 | +# Install dependencies |
| 272 | +npm install |
| 273 | + |
| 274 | +# Build the CLI |
| 275 | +npm run build |
| 276 | + |
| 277 | +# Test locally |
| 278 | +node dist/index.js my-test-app |
| 279 | +``` |
| 280 | + |
| 281 | +## License |
| 282 | + |
| 283 | +MIT © Base |
| 284 | + |
| 285 | +## Support |
| 286 | + |
| 287 | +- [GitHub Issues](https://github.com/base/account-sdk/issues) |
| 288 | +- [Discord](https://discord.gg/base) |
| 289 | +- [Twitter](https://twitter.com/base) |
| 290 | + |
| 291 | +--- |
| 292 | + |
| 293 | +Built with ❤️ by the Base team |
0 commit comments