Quick Start
Get file uploads working in your Next.js app in under 2 minutes with our CLI
Get production-ready file uploads working in your Next.js app in under 2 minutes with our CLI tool. Interactive setup, just one command.
🚀 New! Use our CLI for instant setup: npx @pushduck/cli@latest init
- handles everything automatically!
⚡ Interactive CLI Setup
Get everything set up instantly with our interactive CLI:
npx @pushduck/cli@latest init
pnpm dlx pushduck init
yarn dlx pushduck init
bunx pushduck init
That's it! The CLI will:
- ✅ Auto-detect your package manager (npm, pnpm, yarn, bun)
- ✅ Install dependencies using your preferred package manager
- ✅ Set up your chosen provider (Cloudflare R2, AWS S3, etc.)
- ✅ Create API routes with type safety
- ✅ Generate example components
- ✅ Configure environment variables
- ✅ Create and configure your storage bucket
What you get:
- Production-ready upload API in
app/api/upload/route.ts
- Type-safe upload client in
lib/upload-client.ts
- Example components in
components/ui/
- Working demo page in
app/upload/page.tsx
Example CLI Output:
┌─────────────────────────────────────────────────────────────┐
│ │
│ 🚀 Welcome to Pushduck │
│ │
│ Let's get your file uploads working in 2 minutes! │
│ │
└─────────────────────────────────────────────────────────────┘
🔍 Detecting your project...
✓ Next.js App Router detected
✓ TypeScript configuration found
✓ Package manager: pnpm detected
✓ No existing upload configuration
✓ Project structure validated
? Which cloud storage provider would you like to use?
❯ Cloudflare R2 (recommended)
AWS S3 (classic, widely supported)
DigitalOcean Spaces (simple, affordable)
Google Cloud Storage (enterprise-grade)
MinIO (self-hosted, open source)
Custom S3-compatible endpoint
✨ Generated files:
├── app/api/upload/route.ts
├── app/upload/page.tsx
├── components/ui/upload-button.tsx
├── lib/upload-client.ts
└── .env.example
📦 Installing dependencies with pnpm...
✓ pushduck
✓ @aws-sdk/client-s3
✓ react-dropzone
🎉 Setup complete! Your uploads are ready.
Turbo Mode Issue: If you're using next dev --turbo
and experiencing upload issues, try removing the --turbo
flag. There's a known compatibility issue with Turbo mode that can affect file uploads.
✨ Your Setup Result
This is what you get after running the CLI - try it out!
Drag & drop files or click to browse
Maximum 5 files allowed
Drop files above or click to browse
Step-by-Step CLI Walkthrough
Here's exactly what happens when you run the CLI and how to make the best choices:
Project Detection & Validation
🔍 Detecting your project...
✓ Next.js App Router detected
✓ TypeScript configuration found
✓ Package manager: pnpm detected
✓ No existing upload configuration
✓ Project structure validated
What's happening: The CLI automatically detects your project setup to ensure compatibility.
If you see warnings:
- ⚠️ Pages Router detected: Still works, but examples will be for App Router
- ⚠️ No TypeScript: JavaScript examples will be generated instead
- ⚠️ Existing configuration: CLI will ask if you want to overwrite
- ⚠️ Package manager not detected: Will default to npm
Provider Selection
? Which cloud storage provider would you like to use?
❯ Cloudflare R2 (recommended)
AWS S3 (classic, widely supported)
DigitalOcean Spaces (simple, affordable)
Google Cloud Storage (enterprise-grade)
MinIO (self-hosted, open source)
Custom S3-compatible endpoint
How to choose:
Choose: Cloudflare R2 (recommended)
- Zero egress fees (bandwidth is FREE)
- Global edge network with 200+ locations
- Simple setup with excellent documentation
- Best performance for most applications
Choose: Cloudflare R2
- No egress fees (bandwidth is free)
- $0.015/GB storage (cheaper than S3)
- Global edge network included
- Perfect for high-traffic applications
Choose: Cloudflare R2
- Global edge network with 200+ locations
- Automatic geographic distribution
- Faster uploads worldwide
- Built-in CDN functionality
Choose: Google Cloud Storage
- Enterprise-grade security and compliance
- Advanced analytics and monitoring
- Integration with Google Cloud ecosystem
- Multi-region redundancy options
Use arrow keys to navigate, Enter to select.
Credential Detection & Setup
🔧 Setting up Cloudflare R2...
🔍 Checking for existing credentials...
✓ Found CLOUDFLARE_R2_ACCESS_KEY_ID
✓ Found CLOUDFLARE_R2_SECRET_ACCESS_KEY
✓ Found CLOUDFLARE_R2_ACCOUNT_ID
⚠ CLOUDFLARE_R2_BUCKET_NAME not found
What this means:
- ✅ Found credentials: CLI detected existing environment variables
- ⚠️ Missing credentials: You'll be prompted to enter them
- ❌ No credentials: CLI will guide you through setup
If prompted for credentials:
? Enter your Cloudflare R2 Access Key ID: f1d2...
? Enter your Cloudflare R2 Secret Access Key: [hidden]
? Enter your Cloudflare Account ID: abc123...
? Enter your R2 bucket name: my-app-uploads-2024
Pro tips:
- Use a unique bucket name (globally unique across all R2)
- Account ID can be found in your Cloudflare dashboard
- Don't have credentials? Check our Cloudflare R2 setup guide
Bucket Creation
? Create bucket automatically? (Y/n)
Recommended: Yes - The CLI will:
- Create the bucket with proper permissions
- Set up CORS configuration for web uploads
- Configure public read access for uploaded files
- Test the connection to ensure everything works
Choose "No" if:
- You already have a bucket configured
- Your organization requires manual bucket creation
- You need custom bucket policies
Success looks like:
✅ Created R2 bucket: my-app-uploads-2024
✅ Configured CORS for web uploads
✅ Set up public read permissions
✅ Connection test successful
API Route Configuration
? Where should we create the upload API?
❯ app/api/upload/route.ts (recommended)
app/api/s3-upload/route.ts (classic)
Custom path
Recommendations:
/api/upload
: Clean, modern route name/api/s3-upload
: If you want to be explicit about S3- Custom path: If you have specific routing requirements
The CLI will create:
- Type-safe API route with validation
- Authentication middleware (ready to customize)
- Support for multiple upload types (images, documents)
- Proper error handling and responses
Component Generation
? Generate example upload page?
❯ Yes, create app/upload/page.tsx with full example
Yes, just add components to components/ui/
No, I'll build my own
Choose based on your needs:
Full example page - Best for:
- Learning how the library works
- Quick prototyping and testing
- Getting a working demo immediately
Components only - Best for:
- Adding uploads to existing pages
- Custom UI integration
- Building your own demo
No components - Best for:
- Experienced developers
- Custom implementation requirements
- API-only usage
File Generation & Installation
🛠️ Generating files...
✨ Created files:
├── app/api/upload/route.ts # Type-safe API endpoint
├── app/upload/page.tsx # Demo upload page
├── components/ui/upload-button.tsx # Simple upload button
├── components/ui/upload-dropzone.tsx # Drag & drop component
├── lib/upload-client.ts # Type-safe client
└── .env.example # Environment template
📦 Installing dependencies with pnpm...
✓ pushduck
✓ @aws-sdk/client-s3
✓ react-dropzone
🎉 Setup complete! Your uploads are ready.
What happens:
- Files generated with your specific configuration
- Dependencies installed using your detected package manager
- Types generated for full TypeScript support
- Environment configured with your settings
Package Manager Support:
- npm:
npm install
commands - pnpm:
pnpm add
commands - yarn:
yarn add
commands - bun:
bun add
commands
Next steps shown:
🚀 Next steps:
1. Start your dev server: pnpm dev
2. Visit: http://localhost:3000/upload
3. Try uploading a file!
📚 Learn more:
• API Reference: /docs/api
• Providers: /docs/providers
• Examples: /docs/examples
Common CLI Scenarios
First-Time Setup (Recommended)
npx @pushduck/cli@latest init
# Follow prompts, choose Cloudflare R2, let CLI create bucket
pnpm dlx pushduck init
# Follow prompts, choose Cloudflare R2, let CLI create bucket
yarn dlx pushduck init
# Follow prompts, choose Cloudflare R2, let CLI create bucket
bunx pushduck init
# Follow prompts, choose Cloudflare R2, let CLI create bucket
Quick Cloudflare R2 Setup
# Works with any package manager
npx @pushduck/cli@latest init --provider cloudflare-r2
pnpm dlx pushduck init --provider cloudflare-r2
yarn dlx pushduck init --provider cloudflare-r2
bunx pushduck init --provider cloudflare-r2
AWS S3 Setup
# Skip provider selection, go straight to AWS S3
npx @pushduck/cli@latest init --provider aws
# Use AWS S3 for existing AWS infrastructure
Components Only
# Generate API and components, no demo page
npx @pushduck/cli@latest init --skip-examples
Preview Mode
# See what would be created without making changes
npx @pushduck/cli@latest init --dry-run
Need help? The CLI includes built-in help: npx @pushduck/cli@latest --help
. For detailed documentation, see our complete CLI reference.