avatarAnjal Binayak Adhikari

Summary

The web content provides a step-by-step guide on how to create a Next.js project in 2024, including setup instructions, configuration options, and initializing the project.

Abstract

The article "How to Create a Next.js Project in 2024" is a comprehensive tutorial aimed at developers looking to leverage the Next.js framework for their projects. It begins by highlighting the popularity and benefits of Next.js, particularly its ability to allow developers to focus on building features that matter. The guide outlines the necessary steps to initiate a new Next.js project, from navigating to the desired directory in the file explorer to running the project on a local server. It details the use of the command line interface to execute the npx create-next-app command, followed by making choices for additional features such as TypeScript, ESLint, Tailwind CSS, and the organization of code within a src directory. The article also touches on the decision between using the traditional page router or the newer app router, customizing import aliases, and finally, verifying the successful setup of the Next.js application by running it on localhost:3000.

Opinions

  • The author has been using Next.js since 2021 and has not switched to any other framework due to Next.js's robust features.
  • Next.js is highly regarded in the developer community for its focus on enabling developers to build meaningful features without distraction.
  • The tutorial suggests that many developers, especially those building SaaS products independently, are adopting Next.js as their full stack framework of choice.
  • The author provides a personal preference by choosing not to use TypeScript initially but leaves the option open for those who wish to include it.
  • The use of ESLint and Tailwind CSS is presented as optional choices that can be configured during the project setup process.
  • The author recommends that beginners start with the traditional page router to familiarize themselves with Next.js before moving on to the more advanced app router.
  • The option to customize import aliases is presented as a matter of personal preference, with examples provided for both the default and custom configurations.
  • The article concludes with a congratulatory note, celebrating the reader's successful creation of a new Next.js project.

How to Create a Next.js Project in 2024

Nextjs is a full stack frontend framework built on top of Reactjs

I have been using Nextjs since 2021. I have never switched from Nextjs since then because of the features it provides.

Nextjs is well loved by developer community because it lets developer focus on the building thing that matters.

So, many developers have started adopting Nextjs as their full stack framework, especially Indie SaaS Developers.

This tutorial guides you step-by-step to create a new Nextjs Project.

To create a new Nextjs project, follow these steps

Go to the File Explorer and open directory where you want to create project

Open directory in your file explorer where you want to create new project

Open CMD in the directory

Type CMD in the address bar of the file explorer and press ENTER

After the Command Prompt (CMD) opens, we have to type some command for creating new Nextjs project

Type the following command

npx create-next-app project-name

After this, you will be asked to make the different choices.

Choose, Yes if you want to create Nextjs app with Typescript. I am choosing No for now

This option is for choosing to create project with or without ESLint

You can configure Tailwind CSS by default in Nextjs project, you can choose yes, if you want to setup Tailwind CSS in installation itself

You can put all the code inside the src directory. It makes the project structure cleaner and concise.

If you are a beginner, and just getting started with nextjs then don’t use app router for now. Get familiar with the usual (page router).

But if you are already experienced, you can choose App Router. App Router has lots of benefits and mind blowing features.

It is a option for customizing import alias.

If you choose No, your component import will look like

import UserProfile from @/components

If you choose Yes, you can set custom alias, for-example ‘app’

Now your component import will look like

import UserProfile from @app/components

You can choose as per your likings.

Installation Started

Now the projects start getting initialized.

After, installation completes.

Go inside the project in terminal by following command

cd project-name

and type following command to run Nextjs app

npm run dev

After that, You will see something like this

This means, your project is setup successfully.

Now go to your browser and type localhost:3000

You will see this view.

Congratulations, you have successfully created a new Next.js project. 🎉

PlainEnglish.io 🚀

Thank you for being a part of the In Plain English community! Before you go:

Nextjs
Nextjs Tutorial
Typescript
Recommended from ReadMedium