Skip to content

Deployment Overview

EreoJS runs anywhere Bun runs. Since the framework produces a standard Bun server binary with no proprietary runtime requirements, you have full flexibility in choosing where and how to deploy. Whether you prefer a managed serverless platform, a container orchestrator, or a bare-metal VPS, the deployment process follows the same core pattern: build, configure environment variables, and start.

Choosing a Platform

Not sure where to deploy? Use this decision guide:

  • Need zero-config deploys? Try Vercel or Railway. Both detect EreoJS projects automatically and handle build settings for you.
  • Need edge performance? Cloudflare runs your application at the edge in 300+ locations worldwide, minimizing latency for global users.
  • Need full control? Docker or Bun self-hosted give you complete ownership of the runtime, networking, and scaling decisions.
  • Need global multi-region deployment? Fly.io makes it straightforward to run instances in multiple regions with automatic request routing to the nearest node.

Platform Comparison

PlatformBest ForScalingCostSetup Complexity
Bun (Self-Hosted)Full control, custom infrastructureManual (PM2, systemd)Server costs onlyMedium
DockerContainerized environments, KubernetesContainer orchestrationVaries by hostMedium
VercelServerless, rapid iterationAutomatic, per-requestFree tier, then usage-basedLow
CloudflareEdge-first, global distributionAutomatic, edge-basedFree tier, then usage-basedLow-Medium
Fly.ioFull-stack apps, global regionsAutomatic, multi-regionFree tier, then usage-basedLow
RailwaySimple deployment, databases includedAutomaticFree tier, then usage-basedLow

Quick Deploy

The fastest way to deploy any EreoJS app:

bash
# Build for production
bun run build

# Start the production server
bun start

For platform-specific deployment, use the ereo deploy command:

bash
# Deploy to Vercel
bun ereo deploy --target vercel

# Deploy to Cloudflare
bun ereo deploy --target cloudflare

# Deploy to Fly.io
bun ereo deploy --target fly

# Deploy to Railway
bun ereo deploy --target railway

The deploy command handles platform-specific build adapters, output formatting, and configuration generation automatically.

Environment Variables

Production environment variables should be configured through your deployment platform's dashboard or CLI -- never commit .env files to version control.

General best practices:

  • Use your platform's environment variable UI or CLI to set secrets (database URLs, API keys, etc.)
  • Add .env, .env.local, and .env.production to your .gitignore file
  • Use .env.example to document which variables your app requires, without including actual values
  • EreoJS reads process.env at runtime, so variables set on the platform are available in loaders and actions
bash
# Example: setting env vars via platform CLI
# Vercel
vercel env add DATABASE_URL

# Railway
railway variables set DATABASE_URL=postgres://...

# Fly.io
fly secrets set DATABASE_URL=postgres://...

For a complete guide on managing environment variables across development and production, see the Environment Variables guide.

Build Optimization

EreoJS applies several optimizations during bun run build, but you can further improve production performance:

  • Tree-shaking: EreoJS eliminates unused code automatically. Keep imports specific (e.g., import { signal } from '@ereo/state' rather than import * as state from '@ereo/state') to help the bundler remove dead code.
  • Minification: Production builds are minified by default. No additional configuration is needed.
  • Static generation: For pages that do not depend on request-time data, consider using static generation (export const prerender = true in your route) to serve pre-built HTML with zero server overhead.
  • Asset hashing: Static assets receive content hashes in their filenames for optimal cache headers. The framework handles cache-busting automatically.

Health Checks

Most deployment platforms require a health check endpoint to monitor your application. Add a simple health route to your project:

ts
// app/routes/api/health.ts
export function loader() {
  return new Response(JSON.stringify({ status: 'ok', timestamp: Date.now() }), {
    headers: { 'Content-Type': 'application/json' },
  })
}

Configure your platform's health check to GET /api/health and expect a 200 response. This ensures the platform can detect and restart unhealthy instances.

First Deployment

New to deployment? The First Deployment quickstart walks you through deploying an EreoJS app from scratch, including environment setup, build verification, and going live.

Platform Guides

Each platform guide covers setup, configuration, and platform-specific optimizations in detail:

  • Bun (Self-Hosted) -- Run EreoJS directly on a VPS or dedicated server with full control over the runtime and networking.
  • Docker -- Containerize your EreoJS app for use with Docker Compose, Kubernetes, or any container platform.
  • Vercel -- Deploy serverless with automatic previews for every pull request and built-in analytics.
  • Cloudflare -- Run at the edge with Cloudflare Workers for ultra-low latency globally.
  • Fly.io -- Deploy full-stack applications with multi-region support and persistent volumes for databases.
  • Railway -- One-click deploys with integrated databases, cron jobs, and team collaboration built in.

Released under the MIT License.