bestof2

Dual-Cloud Deployment Engine: Frontend on Cloudflare Pages + Backend on AWS Lambda Web Functions
483
Install
npm install bestof2
Latest Version:0.1.2
License:MIT
Last Updated:Oct 24, 2026
Links: GitHub  ·  npm
Maintainer: bestof2~

bestof2 🏆

"Frontend on Cloudflare Pages (100% Free CDN). Backend on AWS Lambda Web Functions. One single command."

The zero-lockin, dual-cloud deployment engine for modern JavaScript full-stack frameworks, decoupled monorepos, and Node.js backends. Single unified domain. Zero adapters. Zero DevOps. 100% Framework Agnostic.

bestof2 3 Purely Separate Architectures


⚡ GitHub Actions (Primary CI/CD Workflow)

BestOf2 is designed strictly to be zero-touch in your GitHub Actions pipeline. Add .github/workflows/deploy.yml:

name: Deploy with BestOf2
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22

      - name: Deploy to Cloudflare Pages + AWS
        env:
          CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          BESTOF2_SECRET: ${{ secrets.BESTOF2_SECRET }}  # Pulled for secure token rotation
          # Optional AWS credentials (if deploying to AWS Lambda Web Functions):
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          AWS_DEFAULT_REGION: "us-east-1"
        run: npx bestof2 deploy
  • If AWS is configured: Backend auto-deploys to AWS Lambda Web Functions.
  • If AWS is NOT configured: Backend builds as container image for GHCR, frontend deploys to Cloudflare Pages, and BESTOF2_SECRET is pulled from GitHub Secrets so you can run on any VPS with -e BESTOF2_SECRET="$BESTOF2_SECRET".

🚀 Supported Frameworks & Architectures (98% of the Web)

bestof2 automatically detects your project architecture at build time with zero configuration:

Framework / Architecture Frontend Target (Cloudflare Pages) Backend Target (AWS Lambda Web Functions) Edge Networking
Next.js (App & Pages Router) .next/static/* + public/* .next/standalone/server.js Auto-wired (_worker.js)
Nuxt 3 / Nuxt 4 (Nitro Engine) .output/public/* .output/server/index.mjs Auto-wired (_worker.js)
SvelteKit build/client/* build/index.js (adapter-node) Auto-wired (_worker.js)
Astro SSR dist/client/* dist/server/entry.mjs (@astrojs/node) Auto-wired (_worker.js)
React Router v7 / Remix build/client/* build/server/index.js Auto-wired (_worker.js)
Decoupled Monorepo (frontend/ + backend/) frontend/dist/* (Vite / React / Vue) backend/server.js (Express / Hono) Auto-wired /api/* (Zero CORS)
Pure Frontend SPAs (Vite, React, Vue) dist/* None (0 compute, $0 bill) Direct CDN
Pure Backend APIs (Express, Fastify, Hono, NestJS) None Node.js Server on :8080 Direct Lambda Web URL

🛡️ Raw Lambda URL Shielding & Security

When AWS Lambda Web Functions are deployed, AWS assigns an endpoint URL. BestOf2 completely shields this URL from public exposure:

  1. Single Public URL: End users and browsers ONLY ever see https://yourdomain.com (or your-app.pages.dev). The raw Lambda URL is never exposed.
  2. Secret Header Handshake (x-bestof2-secret):
    • At deploy time, BestOf2 injects a cryptographic secret token into Cloudflare Pages environment variables (BESTOF2_SECRET).
    • On every proxied request, Cloudflare's _worker.js injects x-bestof2-secret: <token>.
    • Any direct hit to the raw Lambda endpoint bypasses Cloudflare and returns 403 Forbidden.
  3. Zero CORS Issues for Monorepos: Because frontend/ and backend/ live under the exact same domain, cookies, authentication headers, and fetch calls work with zero cross-origin configuration.

Related Packages

@rekhu/assistant-node

Rekhu Assistant for Node.js: a custom AI assistant inside your app, for your own...

893
@allturko/nabiz-node

Nabız Hub için Node.js raporlayıcı — sunucu hataları, SSR hataları, yavaş istekl...

1,336 0
@truplexy/server

Typed Truplexy customer chat API client and widget server route. Keeps your chat...

1,441
@mergehez/dokie-node

A Node.js package for serving the Dokie API documentation UI across generic serv...

767 22
cauthy-auth

Sign in with Cauthy: one route to mount, getSession on the server, useSession in...

2,148

Version History

Version Released License
0.1.2 MIT
0.1.1 MIT
0.1.0 MIT
0.0.1 MIT
Pre-releases (1)
Version Released License
0.0.0-stage