DEV Community

Wheval
Wheval

Posted on • Edited on

How to Create React/Next.js App with a Fresh GitHub Repo

In this article, you will be creating a super-simple Nextjs/React application locally and a GitHub repository linked to this application.

What do I need? (software used)
Visual Studio Codefor writing the code.
Google Chrome — f_or viewing your application._
Nodejsfor installing other required packages.
GitHubfor hosting your source code online.
Git — for file tracking.

How do you Install it?
Installation information is not provided here. Bookmark this page, while you find out how to install it.

Let’s get to the fun part.
In three steps,

Step 1 — Create a GitHub Remote Repository

Go to GitHub’s website here. Log in or Create an account.
Click the + icon on the menu bar of your account. And create a new repository.

Screenshot from github.com

Configure your repository, by giving it a name. (in my case, newapp)

Image description

IMPORTANT: Do not select “Add a README file”. Similarly, Do not “Add .gitignore”.

Image description

Step 2 — Create your Application Locally

In your desired folder/directory on your PC, run the following command to create your Nextjs app.

npx create-next-app@latest newapp
cd newapp
Enter fullscreen mode Exit fullscreen mode

Optionally, to create your react app, run the following commands in your terminal

npx create-react-app newapp
cd newapp
Enter fullscreen mode Exit fullscreen mode

Step 3 — Connect Local Application to Remote Repository

In the specified folder/directory, run the following commands on your terminal.

git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/your-username/your-repo-name.git
git push -u origin main
Enter fullscreen mode Exit fullscreen mode

Replace “your-username” and “your-repo-name” with your GitHub username and repository.

Final Step- GET CODING!!.

At this point, you’re good to go.
Open your project in VSCode or any editor of your choice and code!!

Top comments (2)

Collapse
 
9opsec profile image
9opsec

Good quick start example for those new to NextJS.

Collapse
 
whevaltech profile image
Wheval

Thank you.