Packaging for Launch — Deploy to Vercel

In this chapter, you will learn how to package a locally developed blog project and deploy it to the internet for free, obtaining a public access link.


Build the production bundle

During development, runnpm run dev, Vite starts a local development server with hot module replacement support.

What you need for deployment isthe optimized and minified production bundle.。

$ npm run build

After execution, the following is generated in the project root directorydist/folder:

dist/
├── index.html                # 入口 HTML
├── assets/
│   ├── index-Df3aBc9x.js    # 打包压缩后的 JS
│   ├── index-Gh7jKl2m.css   # 提取并压缩后的 CSS
│   └── ...
├── posts.json                # public 目录文件原样复制
└── favicon.svg               # 静态资源

Key changes:

  • Filenames include a hash (the hash changes when content changes, used for browser cache control)
  • Code is minified and tree-shaken (removes unused code)
  • The contents of the public/ directory are copied as-is to the root directory

To preview the build result: runnpx vite preview, which starts a local server in production mode to simulate the live environment.


Push the project to GitHub

Step 1: Create a GitHub repository

On GitHub, click + → New repository, and fill in:

  • Repository name:react-blog-app
  • Set it 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 "初始化 React 博客项目"
$ git branch -M main
$ git remote add origin https://github.com/你的用户名/react-blog-app.git
$ git push -u origin main

Before pushing, make sure.gitignorecontainsnode_modulesanddist. node_modules should not be uploaded (it can be restored via npm install), and dist is automatically generated by the build platform.


Vercel deployment

Vercelis currently the most popular front-end deployment platform, with zero-config support for React/Vite projects.

Deployment steps

  1. Visitvercel.com, log in with your GitHub account
  2. Click "New Project" → Import Git Repository → select react-blog-app
  3. Vercel automatically detects Vite + React and fills in the configuration automatically
  4. Click "Deploy" and wait a few dozen seconds
  5. After successful deployment, you get a link such as:https://react-blog-app.vercel.app
Configuration itemValueDescription
Framework PresetViteAuto-detection
Build Commandnpm run buildAuto-detection
Output DirectorydistAuto-detection

Automatic deployment

From then on, every timegit push, Vercel automatically: pulls the code → npm install → npm run build → deploys to production.

The entire process is fully automatic: push and it goes live.


Custom domain (optional)

  1. Vercel project Dashboard → Settings → Domains
  2. Enter your domain (e.g., blog.example.com)
  3. Add a CNAME record at your DNS provider pointing tocname.vercel-dns.com
  4. Wait for DNS to take effect; Vercel automatically applies for an SSL certificate

Next learning directions

Learning directionWho it's forRecommended starting point
TypeScript + ReactWant to write more rigorous, large-scale projectsAdd TypeScript to the project, starting with Props and Hook types
Next.jsNeed SEO, SSR, and full-stack capabilitiesA React-based full-stack framework where files are routes
React Query (TanStack Query)Need more powerful data fetching managementCaching, automatic re-fetching, optimistic updates
State management libraryApplication state logic is very complexZustand (lightweight), Redux Toolkit (heavyweight)
Component libraryQuickly build admin dashboardsAnt Design、MUI、shadcn/ui

React vs Vue3 Full-stack Roadmap Comparison

DirectionReact ecosystemVue3 ecosystem
Full-stack frameworkNext.jsNuxt.js
Type systemTypeScript (better native support)TypeScript
State management (lightweight)ZustandPinia
Data fetchingReact QueryVueUse / TanStack Query
MobileReact Native— (Weex has been discontinued)

You have completed the most important step — building a real project completely with React. Whether you later move on to TypeScript or Next.js, you are adding a new dimension on top of what you already have. React's way of thinking (state-driven views, componentization, one-way data flow) will play a role in every project you build afterward.

Other extensions