Examples & Recipes
Real-world examples and recipes for common deployment scenarios.
Framework Deployments
Section titled “Framework Deployments”React Application
Section titled “React Application”-
Build your React app:
Terminal window npm run build -
Deploy the build folder:
Terminal window bantam deploy ./build -p -s my-react-app -
Your app is live at
my-react-app.bantam.site
Vue.js Application
Section titled “Vue.js Application”# Build for productionnpm run build
# Deploy dist folderbantam deploy ./dist -p -s my-vue-app
Next.js Static Export
Section titled “Next.js Static Export”# Build and export static filesnpm run buildnpm run export
# Deploy the out directorybantam deploy ./out -p -s my-nextjs-site
Astro Site
Section titled “Astro Site”# Build your Astro sitenpm run build
# Deploy the dist folderbantam deploy ./dist -p
Documentation Sites
Section titled “Documentation Sites”Deploy Docs with Custom Domain
Section titled “Deploy Docs with Custom Domain”Perfect for project documentation:
# Build your docsnpm run docs:build
# Deploy to custom domainbantam deploy ./docs/dist -d docs.myproject.com
Versioned Documentation
Section titled “Versioned Documentation”Deploy multiple versions:
# Deploy v1bantam deploy ./docs/v1 -d v1-docs.example.com
# Deploy v2bantam deploy ./docs/v2 -d v2-docs.example.com
# Deploy latest as mainbantam deploy ./docs/latest -d docs.example.com
Development Workflows
Section titled “Development Workflows”Quick Preview Links
Section titled “Quick Preview Links”Share work-in-progress with teammates:
# 1-day preview for quick feedbackbantam deploy ./preview -e 1 -s feature-preview
Staging Deployments
Section titled “Staging Deployments”# Permanent staging environmentbantam deploy ./build -p -s staging-app
# Production deploymentbantam deploy ./build -p -d app.company.com
PR Preview Deployments
Section titled “PR Preview Deployments”In your CI/CD pipeline:
name: Deploy Previewon: pull_request
jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - run: npm install - run: npm run build - run: npx @bantamhq/cli deploy ./dist -s pr-${{ github.event.number }}
Static Site Examples
Section titled “Static Site Examples”Simple HTML Site
Section titled “Simple HTML Site”# Deploy a basic websitebantam deploy ./my-website -p
Directory structure:
my-website/├── index.html├── about.html├── css/│ └── style.css└── js/ └── script.js
Landing Page
Section titled “Landing Page”# Create a landing pagemkdir landingcd landingecho '<!DOCTYPE html><html><head> <title>Coming Soon</title> <style> body { font-family: sans-serif; text-align: center; padding: 50px; } </style></head><body> <h1>Coming Soon!</h1> <p>Something awesome is in the works.</p></body></html>' > index.html
# Deploy itbantam deploy -p -s coming-soon
Advanced Patterns
Section titled “Advanced Patterns”Multiple Environments
Section titled “Multiple Environments”# Developmentbantam deploy ./dist -s myapp-dev
# Stagingbantam deploy ./dist -s myapp-staging
# Productionbantam deploy ./dist -s myapp-prod
# Developmentbantam deploy ./dist -d dev.myapp.com
# Stagingbantam deploy ./dist -d staging.myapp.com
# Productionbantam deploy ./dist -d myapp.com
Automated Deployments
Section titled “Automated Deployments”Package.json Script
Section titled “Package.json Script”{ "scripts": { "deploy": "npm run build && bantam deploy ./dist -p", "deploy:staging": "npm run build && bantam deploy ./dist -p -s staging", "deploy:prod": "npm run build && bantam deploy ./dist -p -d example.com" }}
Usage:
npm run deploy:staging
Shell Script
Section titled “Shell Script”Create deploy.sh
:
#!/bin/bashset -e
echo "Building project..."npm run build
echo "Running tests..."npm test
echo "Deploying to Bantam..."bantam deploy ./dist -p -s production
echo "✅ Deployment complete!"
Make executable and run:
chmod +x deploy.sh./deploy.sh
Special Use Cases
Section titled “Special Use Cases”Password-Protected Preview
Section titled “Password-Protected Preview”While Bantam doesn’t support password protection via CLI, you can:
- Deploy temporarily
- Add protection via web dashboard
- Share secure link
# Deploy for 7 daysbantam deploy ./sensitive-preview -e 7
Large File Handling
Section titled “Large File Handling”For projects near size limits:
# Remove development filesrm -rf node_modulesrm -rf .git
# Create optimized archivezip -r dist.zip dist/ -x "*.map" "*.log"
# Deploy the zipbantam deploy dist.zip -p
Static Blog Deployment
Section titled “Static Blog Deployment”Deploy a Jekyll or Hugo blog:
# Build Jekyll sitebundle exec jekyll build
# Deploy _site folderbantam deploy ./_site -p -s my-blog
# Build Hugo sitehugo
# Deploy public folderbantam deploy ./public -p -s my-blog
Next Steps
Section titled “Next Steps”- Explore all commands in detail
- Set up authentication for premium features
- Learn about custom domains