From the course: Learning Next.js

Getting started with the Next.js tooling

From the course: Learning Next.js

Getting started with the Next.js tooling

- Starting with Next.js is very simple. The official website helps you get started quickly with the requirements and installation. In order to get ready fast and to make the best of your Next.js experience. So in order to get started, you're going to head to the documentation, the official website and find the sections getting started and we're going to find first the system requirements and the recommendation in order to get started and you should have absolutely installed on your machine the latest version of Node starting from version 12.22 or later it's going to work just fine. Otherwise you can go to the official website of Node and find the latest and must able version and follow the steps in order to install the latest copy of Node for your operating system. The recommendation from the official website is to use the automatic setup with create next-app, which is a tool chain to set up everything automatically for you. You will see that it will take seconds to set up a new Next.js project with everything you need with every file, every dependency necessary in order for you to get started quickly with your Next.js experience and I'll show you how to do that. So here is the official page for the Chrome extension React Developer Tools. In your case, you should read add to Chrome because it's already installed in my case you'd remove from Chrome, but you should read add to Chrome to install this one. And this is an excellent extension and tool for your development process because it's going to help for your development but also debug, to debug when you find any technical issues in your application. So you're afraid to use either package manager of your choice in order to install the tool chains. So either NPM or Yarn. So the latest Yarn has been proven to install the dependencies faster, but the easiest way to get started with Next.js is by using the tool chain, which is create next-app. So you should start by first installing this one with either NPM or Yarn followed by create next-app. And then you'll be ready to create a new application by running NPX create next-app followed by the name of your project. So the common line interface enables you to quickly start building a Next.js application with everything set up for you. So I'll go ahead and open the code editor in order to create a new Next.js application. So as a reminder for every demonstration, you're going to get a beginning state and end state in order to see the final version of every exercise. So with CD, it is for change directory. I'm going to move to chapter two. So inside I'm going to run NPX create next-app. So this is the tool chain followed by. So you can pick the name that you'd like. So I'm going to name my app, my next-app like this and I'm going to click enter to run the tool chain and then it's going to create a new project for me. Here you go, so now we're going to find out what we have inside. So I'm going to open, so here we're going to find out the anatomy of this application starting with the package.json which is the manifest of your application with all the dependencies, the properties and meta data, information about your application starting with the name, the version and the scripts as well. So we're going to use this one to run the app locally. We have other informations like the Node modules that includes all the dependencies and pages which is one location where we're going to spend most of the time to define the pages and create the views of the application. You also have the styles directory that includes the CSS to change the appearance and make your application look good and inside pages you have another subdirectory, which is API which is to define the routes that only applies to the server in order to make API calls. So congratulations, you have successfully created your first Next.js applications. So now we're going to give it a spin and start the application by simply running inside the terminal. And just so if you're using visual studio code you can go here view and open the terminal like this to have the terminal and me, I'm just going to run npm run dev and that's going to start the application. So I should also remember also to move to my new app before doing that. So I'm going to change directory, my next-app and then run npm run dev. And it's going to start the application on local host 3000. And we're going to check this one out on the port 3000 and see how this looks. Here we go, so this opens up the starting page of the Next.js applications which is now visible on the local hosts 3000. So you are now all set. You have successfully created your first ever Next.js application. Now you're ready to start your journey with learning the concepts of Next.js and remember that whenever you need a refresher you can always head to the documentation and then see the steps in order to get started quickly with Next.js.

Contents