/create-react-spa-cloudflare

Starter package for react spa with cloudflare pages, workers, and kv

Primary LanguageTypeScript

Create React SPA Cloudflare

A starter project for building a pnpm monorepo with a client-side React SPA and a server-side Cloudflare Worker with KV storage. This project includes comprehensive testing, linting, and CI/CD setup, along with Sentry integration for error tracking.

Features

  • React SPA for the client-side application
  • Tailwind CSS for styling
  • Tanstack Query for client http request state management
  • Hono server-side api framework
  • Prettier for code formatting
  • ESLint for linting
  • Vitest for unit testing
  • Playwright for end-to-end testing
  • TypeScript for type checking
  • Cloudflare Pages for hosting the client, Worker with KV storage for hosting the server
  • GitHub workflows for CI and staging deployment
  • Sentry integration for client-side error tracking
  • pnpm for performant monorepo package management

Installation

Pre-requisites

  1. git
  2. pnpm v9 and above
  3. node v22.9.0 and above

Install

  1. Ensure you're using the correct version of Node:
    nvm use 22.9.0
  2. If necessary, install the correct version of pnpm:
    npm i -g pnpm@9
  3. Run the installation script:
    pnpm create react-spa-cloudflare@latest my-app
  4. Check the console output for any warnings. The command will succeed unless the initial download fails.

Getting Started

  1. Navigate to your project directory and start the development server:
cd my-app
pnpm run dev
  1. Navigate to the app at http://localhost:5173
  2. You should see some hello text, components, and verified server connection
  3. Follow your project's README for further setup instructions

Debug

ENOENT Error

If you encounter an ENOENT error when running the create command, make sure to include a version:

# ❌ Wrong! It's missing a version
pnpm create react-spa-cloudflare

# ✅ Correct!
pnpm create react-spa-cloudflare@latest