How to Install and Set Up a New Next.js Project on Ubuntu

 

How to Install and Set Up a New Next.js Project on Ubuntu

Introduction

Next.js is a popular React framework that enables developers to build fast, scalable, and SEO-friendly web applications. This guide will show you how to set up a Next.js project on an Ubuntu system.

Prerequisites

  • An Ubuntu system (20.04 or later recommended)
  • Node.js installed (version 14 or later)
  • npm (Node Package Manager) or yarn
  • Basic knowledge of the terminal

Step 1: Update System Packages

Before starting, ensure your system packages are up to date. Run the following commands:

sudo apt update
sudo apt upgrade -y

Step 2: Install Node.js and npm

If Node.js is not already installed, use the following commands to install it:

curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt install -y nodejs

Verify the installation:

node -v
npm -v

Step 3: Create a New Next.js Project

Use the create-next-app command to initialize a new Next.js project. Replace my-next-app with your desired project name:

npx create-next-app my-next-app

Alternatively, if you prefer yarn:

yarn create next-app my-next-app

Step 4: Navigate to Your Project Directory

Change into your project directory:

cd my-next-app

Step 5: Start the Development Server

Run the following command to start the development server:

npm run dev

The application will be available at http://localhost:3000.

Step 6: Customize Your Application

Edit the files in the pages directory to start customizing your application. The main entry point is pages/index.js.

Conclusion

Congratulations! You have successfully set up a Next.js project on Ubuntu. Explore the documentation to learn more about building with Next.js.

 

Next.js Documentation

  • 0 Els usuaris han Trobat Això Útil
Ha estat útil la resposta?

Articles Relacionats

Boost Your Ubuntu System's Performance with a Swap File: A Step-by-Step Guide

What is a Swap File? A swap file in Ubuntu serves as dedicated virtual memory on your hard...

How to Migrate ISPConfig 2, ISPConfig 3.x, Confixx, CPanel or Plesk to ISPConfig 3.2 (single server)

Introduction Migration from other control panels like ISPConfig 2, ISPConfig 3.x, Confixx,...

How to Install and Configure Zabbix Server and Client on Rocky Linux 9

Introduction Zabbix is an open-source monitoring solution that provides real-time...

How to Install CockroachDB Cluster on Debian 12

Introduction CockroachDB is a distributed SQL database built to handle large-scale,...

How to Install Joomla with Apache and Let's Encrypt SSL on AlmaLinux 9

Introduction Joomla is a popular open-source content management system (CMS) used to build...