If you’re building a fast, modern web app, Next.js is one of the best frameworks around. It’s built on top of React and gives you features like server-side rendering, static site generation, API routes, and more—out of the box.
In this post, I’ll walk you through how to install and set up a brand new Next.js project on Ubuntu.
Prerequisites
Before you start, make sure you have the following:
- A system running Ubuntu (20.04 or later recommended)
- Node.js and npm installed
- Git installed
Let’s break it down step by step.
Step 1: Update Your System
Open your terminal and run:
sudo apt update && sudo apt upgrade -y
This ensures you’re working with the latest package versions.
Step 2: Install Node.js and npm
Next.js requires Node.js. You can install the latest LTS version using NodeSource:
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt install -y nodejs
To confirm installation:
node -v
npm -v
Step 3: Install Git
If you haven’t already installed Git:
sudo apt install git -y
Verify:
git --version
Step 4: Create a New Next.js Project
Use npx
to create a new project with everything set up:
npx create-next-app@latest my-next-app
You’ll be prompted to choose:
- TypeScript or JavaScript
- ESLint configuration
- Tailwind CSS
- src/ directory structure
Pick what suits your needs, or go with the defaults to keep it simple.
Change into your project directory:
cd my-next-app
Step 5: Run the Development Server
Start the dev server with:
npm run dev
Then go to http://localhost:3000
in your browser. You should see the default Next.js welcome page.
Step 6: Open the Project in a Code Editor
If you use VS Code:
code .
Now you can start editing pages/index.js
or app/page.tsx
(depending on your setup) to build your site.
Bonus: Version Control with Git
Initialize Git if you haven’t:
git init
git add .
git commit -m "Initial commit"
You can now push your project to GitHub or any other remote.
Wrapping Up
That’s it! You’ve set up a new Next.js project on Ubuntu and you’re ready to build. Whether you’re creating a blog, dashboard, portfolio, or full-scale app, Next.js gives you the tools to move fast and scale later.
If you run into issues, check out the Next.js documentation or drop a question in the comments.
Leave a Reply