7/6/25

Intro

Learn how to refactor the Web Dev 101 project into a React app using Vite.

Web Dev 102: React by OC Robotics

Create new branch and backup original files

  • Create branch
git checkout -b webdev102
  • Move files to legacy folder
mkdir legacy && mv index.html style.css script.js legacy/

9/5/25

Setting Up a React Project – Toolchains Overview

There are multiple ways to set up a React project 1, including some popular React toolchains such as:

  • Create React App (CRA) (Deprecated)
  • Gatsby
  • Vite – a modern, fast build tool that’s great for development.
  • Next.js – for full-stack React apps with SSR and routing.

In this setup, we’ll use Vite CLI, a lightweight and ultra-fast build tool, to scaffold a React project. It’s great for modern frontend development and offers near-instant dev server startup.

Create React App Using Vite

  • Make sure you have npm and Node.js installed
node -v
npm -v
  • If you do not have them, follow Installing Node.js via NVM
  • Create React App using Vite CLI (with ., or current directory, as the project name)
npm create vite@latest . --template react
  • Install dependencies
npm install
  • Start the development server
npm run dev
  • Open React app in the browser
http://localhost:5173

Deploying Your Site

GitHub Pages

  • Set the correct base in vite.config.js (i.e. / for user site or /<REPO>/ for project site) 2
  • Install the gh-pages package as a dev dependency:
npm install gh-pages --save-dev
  • Update package.json
  • Deploy app 3
npm run deploy
  • Go to Settings → Pages in GitHub and make sure the branch is set to gh-pages

Vercel

  • Commit changes and push webdev102 branch to GitHub
git push origin webdev102
  • Go to vercel.com and sign in with GitHub
  • Import project- Click “Add New → Project” and select your repo
  • If Vercel doesn’t auto-detect Vite, set the following options:
    • Framework: Vite
    • Build command: npm run build
    • Output directory: dist
  • Click “Deploy”
  • Your site will be live on a *.vercel.app domain (example)

React Hello World

  • Clean up the project so that it no longer displays the default page, but a simple message instead

Add a button

  • Commit and push changes to the branch and the deployment should be triggered automatically (example)

Related

➡️Next: Web Dev 103- Material UI

Footnotes

  1. https://www.theodinproject.com/lessons/node-path-react-new-setting-up-a-react-environment ↩

  2. https://vite.dev/guide/static-deploy.html#github-pages ↩

  3. https://dev.to/rashidshamloo/deploying-vite-react-app-to-github-pages-35hf ↩