# npm 6.x $ npm create vite@latest my-app --template react # npm 7+, extra double-dash is needed: $ npm create vite@latest my-app -- --template react # yarn $ yarn create vite my-app --template react
$ cd my-app $ npm install $ npm run dev
$ npm install gh-pages --save-dev
{ "name": "my-app", "version": "0.1.0", + "homepage": "https://{username}.github.io/{repo-name}",
"scripts": { "dev": "vite", "build": "vite build", "preview": "vite preview", + "predeploy": "npm run build", + "deploy": "gh-pages -d dist" }
export default defineConfig({ + base: "/{repo-name}/", plugins: [react()] })
$ git remote add origin https://github.com/{username}/{repo-name}.git
# deploy without commit message $ npm run deploy # deploy with commit message $ npm run deploy -- -m "some-commit-message"
- Navigate to the GitHub Pages settings page
- In your web browser, navigate to the GitHub repository
- Above the code browser, click on the tab labeled "Settings"
- In the sidebar, in the "Code and automation" section, click on "Pages"
- Configure the "Build and deployment" settings like this:
- Source: Deploy from a branch
- Branch:
- Branch:
gh-pages
- Folder:
/ (root)
- Branch:
- Click on the "Save" button
That's it! The app has been deployed to GitHub Pages!
At this point, the React app is accessible to anyone who visits the homepage
URL you specified earlier