What is Next.js and how to install the project in Next.js
Next.js is a popular and lightweight framework for static and server‑rendered applications built with React. It includes styling and routing solutions out of the box, and assumes that you’re using Node.js as the server environment.
Next.js has the best-in-class "Developer Experience" and many built-in features; a sample of them are:
- An intuitive page-based routing system (with support for dynamic routes)
- Pre-rendering, both static generation (SSG) and server-side rendering (SSR) are supported on a per-page basis
- Automatic code splitting for faster page loads
- Client-side routing with optimized prefetching
- Built-in CSS and Sass support, and support for any CSS-in-JS library
- Development environment with Fast Refresh support
- API routes to build API endpoints with Serverless Functions
- Fully extendable
Next.js is used in tens of thousands of production-facing websites and web applications, including many of the world's largest brands.
Create a Next.js app
To create a Next.js app, open your terminal, cd
into the directory you’d like to create the app in, and run the following command:
npx create-next-app nextjs-app
cd nextjs-app
npm run dev
This starts your Next.js app’s "development server" (more on this later) on port 3000. You should see a page like this when you access http://localhost:3000. This is the starter template page which shows some helpful information about Next.js.