bantam.hostbantam.host
CLI Guide

Deploy React with Bantam CLI

Deploy Create React App projects and custom React builds in seconds

Install Bantam CLI:

npm install -g @bantamhq/cli

View on NPM: @bantamhq/cli

Quick start:

# Build your React app
npm run build

# Deploy it
bantam deploy ./build

Quick Start

1

Install dependencies

Make sure all your React app dependencies are installed

npm install
2

Build your React app

Creates an optimized production build in the ./build directory

npm run build
This typically takes 30-60 seconds depending on your app size
3

Deploy with Bantam

Your React app is now live!

bantam deploy ./build
You'll get an instant URL like https://my-app-abc123.bantam.site

Framework Details

Build Configuration

Create React App provides sensible defaults, but you can customize the build:

Environment Variables:

REACT_APP_API_URL=https://api.example.com npm run build
REACT_APP_VERSION=$npm_package_version npm run build
Only environment variables prefixed with REACT_APP_ are embedded into the build.

Routing Configuration

For React Router apps with client-side routing, you'll need to handle 404s:

Create a _redirects file in your public folder:

/*    /index.html   200
Without this configuration, direct links to routes like /about will return 404.

Build Output

The React build process creates these files in ./build:

  • index.html - Your app's entry point
  • static/js/ - Bundled JavaScript files with hashes
  • static/css/ - Compiled CSS files
  • static/media/ - Images and other assets
File names include content hashes for optimal caching. Bantam serves these with appropriate cache headers.

Advanced Usage

Custom Domain

Deploy directly to your own domain

bantam deploy ./dist --domain myapp.com

Permanent Deployment

Keep your site online forever (requires login)

bantam deploy ./dist --permanent

Custom Expiry

Set how long your deployment stays online

bantam deploy ./dist --expiry-days 7

Custom Subdomain

Choose your own subdomain on bantam.site

bantam deploy ./dist --subdomain my-project

CI/CD Integration

Add Bantam to your continuous deployment pipeline:

# GitHub Actions example
- name: Deploy to Bantam
  run: |
    npm install -g @bantamhq/cli
    bantam login --token ${{ secrets.BANTAM_TOKEN }}
    bantam deploy ./dist --domain myapp.com --permanent
Troubleshooting

Common Issues & Solutions

Quick fixes for deployment challenges

01.Build fails with 'out of memory' error

Large React apps may need more memory during build:

NODE_OPTIONS='--max-old-space-size=4096' npm run build

This allocates 4GB of memory to the Node.js process.

02.Images or fonts not loading after deployment

Check that you're using proper imports for assets:

// ✅ Good - webpack processes the import
import logo from './logo.png';
<img src={logo} alt="Logo" />

// ❌ Bad - won't work in production
<img src="/logo.png" alt="Logo" />

03.Environment variables not working

Remember these rules for React environment variables:

  • Must be prefixed with REACT_APP_
  • Are embedded at build time, not runtime
  • Require a rebuild to change values
# .env.production
REACT_APP_API_URL=https://api.production.com
REACT_APP_FEATURE_FLAG=true

04.How do I deploy a React app that's not using Create React App?

The process is the same - just make sure your build command outputs to a single directory:

# Custom webpack config
webpack --mode production

# Vite-based React app
vite build

# Then deploy the output directory
bantam deploy ./dist

05.Can I use React with server-side rendering?

Bantam hosts static files only. For SSR, you'll need to:

  • Use Next.js with next export for static generation
  • Use a service that supports Node.js for true SSR
  • Pre-render your React app at build time