This repository shows a simple full-stack setup that can be deployed to both Vercel and Cloudflare Workers without monorepo tooling:
frontend/: React + Vite single-page appbackend/: stateless Hono API that fetches data frompokeapi.co
The frontend was bootstrapped with create-vite, and the backend was bootstrapped with create-hono.
Run the backend first:
cd backend
npm install
npm run devThen run the frontend in a second terminal:
cd frontend
npm install
cp .env.example .env
npm run devThe frontend reads VITE_API_BASE_URL. For local development it should point to http://localhost:8787.
Deploy the apps as two separate Vercel projects.
- Import the repository into Vercel.
- Set the project root directory to
frontend. - Use the default Vite build settings:
- Build command:
npm run build - Output directory:
dist
- Build command:
- Set
VITE_API_BASE_URLto your deployed backend URL.
frontend/vercel.json includes the SPA rewrite recommended by Vercel for Vite SPAs.
- Import the same repository into a second Vercel project.
- Set the project root directory to
backend. - Deploy with the default Hono setup. Vercel detects the default export in
src/index.ts.
For local Vercel emulation, use vercel dev inside backend/.
Deploy the apps as two separate Workers projects.
cd frontend
npm install
npm run deploy:cloudflareThis uses the Cloudflare Vite plugin and frontend/wrangler.jsonc. The SPA fallback is configured with assets.not_found_handling = "single-page-application", and the deploy script points Wrangler at the generated dist/wrangler.json output from vite build.
cd backend
npm install
npm run deployThe backend uses the standard Cloudflare Workers Hono setup from create-hono.
- The backend is stateless and only proxies PokeAPI data.
- The frontend is provider-agnostic and talks to the backend through
VITE_API_BASE_URL. - No platform-specific runtime code is required in the React app.
- The current
create-viteoutput uses Vite 8, which expects Node20.19+or22.12+.