|
| 1 | +# Welcome to React Router! |
| 2 | + |
| 3 | +A modern, production-ready template for building full-stack React applications |
| 4 | +using React Router. |
| 5 | + |
| 6 | +## Features |
| 7 | + |
| 8 | +- 🚀 Server-side rendering |
| 9 | +- ⚡️ Hot Module Replacement (HMR) |
| 10 | +- 📦 Asset bundling and optimization |
| 11 | +- 🔄 Data loading and mutations |
| 12 | +- 🔒 TypeScript by default |
| 13 | +- 🎉 TailwindCSS for styling |
| 14 | +- 📖 [React Router docs](https://reactrouter.com/) |
| 15 | + |
| 16 | +## Getting Started |
| 17 | + |
| 18 | +### Installation |
| 19 | + |
| 20 | +Install the dependencies: |
| 21 | + |
| 22 | +```bash |
| 23 | +npm install |
| 24 | +``` |
| 25 | + |
| 26 | +### Development |
| 27 | + |
| 28 | +Start the development server with HMR: |
| 29 | + |
| 30 | +```bash |
| 31 | +npm run dev |
| 32 | +``` |
| 33 | + |
| 34 | +Your application will be available at `http://localhost:5173`. |
| 35 | + |
| 36 | +> Note: Wrangler and the Cloudflare Vite plugin now support dotenv files for local development. |
| 37 | +> Create a `.env` in this app's root (alongside `wrangler.jsonc`) to define local `vars`. |
| 38 | +> For example: |
| 39 | +> |
| 40 | +> ```dotenv |
| 41 | +> TITLE="My Worker" |
| 42 | +> API_TOKEN="dev-token" |
| 43 | +> ``` |
| 44 | +> |
| 45 | +> These will be available on `context.cloudflare.env.TITLE` / `env.API_TOKEN` in worker code during `wrangler dev`. |
| 46 | +> You can also add `.env.<environment>` files (e.g. `.env.staging`) and run `wrangler dev --env staging`. |
| 47 | +
|
| 48 | +## Previewing the Production Build |
| 49 | +
|
| 50 | +Preview the production build locally: |
| 51 | +
|
| 52 | +```bash |
| 53 | +npm run preview |
| 54 | +``` |
| 55 | +
|
| 56 | +## Building for Production |
| 57 | + |
| 58 | +Create a production build: |
| 59 | + |
| 60 | +```bash |
| 61 | +npm run build |
| 62 | +``` |
| 63 | + |
| 64 | +## Deployment |
| 65 | + |
| 66 | +Deployment is done using the Wrangler CLI. |
| 67 | + |
| 68 | +To build and deploy directly to production: |
| 69 | + |
| 70 | +```sh |
| 71 | +npm run deploy |
| 72 | +``` |
| 73 | + |
| 74 | +To deploy a preview URL: |
| 75 | + |
| 76 | +```sh |
| 77 | +npx wrangler versions upload |
| 78 | +``` |
| 79 | + |
| 80 | +You can then promote a version to production after verification or roll it out |
| 81 | +progressively. |
| 82 | + |
| 83 | +```sh |
| 84 | +npx wrangler versions deploy |
| 85 | +``` |
| 86 | + |
| 87 | +## Styling |
| 88 | + |
| 89 | +This template comes with [Tailwind CSS](https://tailwindcss.com/) already |
| 90 | +configured for a simple default starting experience. You can use whatever CSS |
| 91 | +framework you prefer. |
| 92 | + |
| 93 | +--- |
| 94 | + |
| 95 | +Built with ❤️ using React Router. |
0 commit comments