Intro to React Workshop materials that Marcus and I hosted as part of ChaosHacks 2024 workshop
Materials
Setup Prerequisites
- Visual Studio Code
- NPM
- VSCode Extensions
- Vercel account
- GitHub account (optional, but nice to haves for Vercel + Git Integration)
Project Setup
The React project uses Vite
- TypeScript + SWC
and tailwindcss
. Deployment will use Vercel.
- Create the project folder
npm create vite@latest
- Select your project name -
chaoshacks24-react
- Choose
react
as the framework - Choose
TypeScript + SWC
TypeScript
to build your project with full type-safetySWC
(Speedy Web Compiler) is super-fast TypeScript / JavaScript compiler written in Rust.
cd test-project
- Install
tailwindcss
and embed it into projectnpm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
- Configure template paths in
tailwind.config.js
/** @type {import('tailwindcss').Config} */ export default { content: [ "./index.html", "./src/**/*.{js,ts,jsx,tsx}", ], theme: { extend: {}, }, plugins: [], }
- Add tailwind directives in
./src/index.css
@tailwind base; @tailwind components; @tailwind utilities;
- Enjoy development time
npm run dev
- Go to http://localhost:5173/
- Recommended: Deploy with Vercel first, so it helps as another environment to run and test during development
- Deployment with Vercel - Guide (2 initial ways)
- Command Line Interface - Easier but less convenient over time
npm i -g vercel
- Install vercel
vercel
- Set up vercel deployment
- Also used to update and upload project folder to newest build
- Using GitHub - Better Integration and no need to redeploy every time - connected with GitHub.
- Make repository in GitHub
- Go to
vercel.com
and import project from Repository - Everytime code is pushed to GitHub will be automatically redeployed in Vercel
- Command Line Interface - Easier but less convenient over time
Acknowledgements
- https://react.dev/
- https://tailwindcss.com/docs/guides/vite
- https://vitejs.dev/guide/static-deploy#vercel
- nwHacks 2024 Intro to React Slides