This chapter will teach you how to package your locally developed blog project and deploy it to the internet for free, obtaining a public access link.
Building the Production Bundle
During development, run npm run dev to start Vite's local development server with hot module replacement.
For deployment, you need an optimized and compressed production bundle.
$ npm run build
After execution, a dist/ folder is generated in the project root directory:
dist/
βββ index.html # Entry HTML
βββ assets/
β βββ index-Df3aBc9x.js # Bundled and compressed JS
β βββ index-Gh7jKl2m.css # Extracted and compressed CSS
β βββ ...
βββ posts.json # Files from public directory copied as-is
βββ favicon.svg # Static assets
Key changes:
- File names include hashes (hash changes when content changes, for browser cache control)
- Code is compressed and tree-shaken (unused code removed)
- Contents of
public/directory are copied to root as-is
Preview the build result: Run
npx vite previewto start a local production-mode server, simulating the online environment.
Pushing the Project to GitHub
Step 1: Create a GitHub Repository
On GitHub, click + β New repository, and fill in:
- Repository name: react-blog-app
- Set to Public (for free deployment)
- Do NOT check "Initialize with README"
Step 2: Initialize Git and Push
$ cd blog-app
$ git init
$ git add .
$ git commit -m "Initialize React blog project"
$ git branch -M main
$ git remote add origin https://github.com/your-username/react-blog-app.git
$ git push -u origin main
Before pushing, confirm that
.gitignoreincludesnode_modulesanddist. node_modules should not be uploaded (can be restored via npm install), and dist is automatically generated by the build platform.
Vercel Deployment
Vercel is currently the most popular frontend deployment platform, offering zero-config support for React/Vite projects.
Deployment Steps
- Visit vercel.com and log in with your GitHub account
- Click "New Project" β Import Git Repository β select react-blog-app
- Vercel automatically detects Vite + React, with configuration auto-filled
- Click "Deploy" and wait a few dozen seconds
- After successful deployment, obtain a link such as:
https://react-blog-app.vercel.app
| Configuration Item | Value | Description |
|---|---|---|
| Framework Preset | Vite | Auto-detected |
| Build Command | npm run build | Auto-detected |
| Output Directory | dist | Auto-detected |
Automatic Deployment
After this, every git push will automatically trigger Vercel to: pull code β npm install β npm run build β deploy to production.
The entire process is fully automatic β push to deploy.
Custom Domain (Optional)
- Vercel project Dashboard β Settings β Domains
- Enter your domain (e.g., blog.)
- Add a CNAME record at your DNS provider pointing to
cname.vercel-dns.com - Wait for DNS to take effect, Vercel automatically applies for an SSL certificate
Next Learning Directions
| Learning Direction | Suitable For | Recommended Starting Point |
|---|---|---|
| TypeScript + React | Those who want to write more rigorous large-scale projects | Add TS to the project, starting with Props and Hook types |
| Next.js | Those who need SEO, SSR, and full-stack capabilities | A React-based full-stack framework with file-based routing |
| React Query (TanStack Query) | Those who need more powerful data request management | Caching, automatic refetching, optimistic updates |
| State Management Libraries | Applications with very complex state logic | Zustand (lightweight), Redux Toolkit (heavyweight) |
| Component Libraries | Rapidly building admin dashboards | Ant Design, MUI, shadcn/ui |
React vs Vue3 Full-Stack Route Comparison
| Direction | React Ecosystem | Vue3 Ecosystem |
|---|---|---|
| Full-stack Framework | Next.js | Nuxt.js |
| Type System | TypeScript (better native support) | TypeScript |
| State Management (Lightweight) | Zustand | Pinia |
| Data Fetching | React Query | VueUse / TanStack Query |
| Mobile | React Native | β (Weex discontinued) |
The most important step is already complete β you've built a real project with React from start to finish. Whether TypeScript or Next.js comes next, you're adding dimensions on top of an existing foundation. React's way of thinking (state-driven views, componentization, unidirectional data flow) will serve you in every subsequent project.
YouTip