
This package will help us to deploy our code to the gh-pages branch which will be used to host our application on GitHub Pages. In order for us to be able to upload our built application to GitHub Pages, we first need to install the gh-pages package: yarn add gh-pages Now, we can push all our project’s files to our repository. First, we need to configure an upstream branch and set the remote as origin: git push -set-upstream origin master Note: It’s important to call the remote origin as it will be used in our deploy process.Īfter executing the command above, we still can’t push our code just yet. So, in our case, the command looks like this: git remote add origin To do that, type the following in the terminal: git remote add We are going to add this repository as a remote to our project. If you mark it as private, you won’t be able to use GitHub Pages. Note: Make sure to mark your repository as public. Head over to your GitHub account and create a repository with the same name as the React project. So before we move on, we must have our project uploaded there.

You may have noticed that we have not created any repository in GitHub. If everything runs properly, you will see a message in the terminal that says that your application is running on a local server at this address: If you head over there in your browser, you’ll see this: To see if it works properly, head to the directory of the project (in our example it would be starter-project) and run the following command: yarn start Once the operation finishes, you’ll have a boilerplate React project ready to go. To create a project, you need to type the following in the terminal: npx create-react-app starter-project It is a package that lets you create a single page application with ease. To create our project, we will be using create-react-app. Choose whichever name you deem fit for this project, but I will go with starter-project for the rest of this article. Head over to your account and create a new repository. We’ll also need to create a repository on GitHub. If not, you need to install what’s missing.

If these commands print out a version number in the terminal, you’re good to go. To check if they’re installed, open a terminal window and type the following: npm -v yarn -v node -v You need to have Node, Yarn and npm installed on your machine.
