Setting Up Your First Next.js Project: A Beginner's Guide
Learn how to initialize a Next.js project using the App Router and CLI. Start your development server and explore the project structure for your first app.
Welcome to the first step in building a professional-grade, full-stack blog. In this course, we will use the Next.js framework to create a performant, SEO-friendly application powered by the modern App Router.
Before we dive into architecture or database operations, we must establish a solid foundation. This lesson focuses on using the CLI to scaffold your environment and understanding the files generated by the framework.
Initializing Your Next.js Project
The standard way to bootstrap a new application is via create-next-app. This CLI tool sets up everything you need, including TypeScript, ESLint, and Tailwind CSS configurations.
Open your terminal and run the following command:
Bashnpx create-next-app@latest my-blog
When prompted, I recommend the following production-grade defaults:
- TypeScript: Yes
- ESLint: Yes
- Tailwind CSS: Yes
src/directory: Yes (this keeps your root folder clean)- App Router: Yes (the modern standard for Next.js)
- Import alias:
@/*(default)
Once the command finishes, navigate into your project folder:
Bashcd my-blog
Navigating the Project Directory
Modern Next.js projects follow a specific structure that separates your configuration from your application code. By choosing the src/ directory option, your project will look like this:
| File/Folder | Purpose |
|---|---|
src/app/ | The heart of the App Router; contains your routes and pages. |
public/ | Static assets like images or fonts that are served directly. |
tailwind.config.ts | Configuration for your CSS utility classes. |
next.config.ts | Advanced framework settings and redirects. |
tsconfig.json | TypeScript compiler options. |
The src/app/ directory is where we will spend 90% of our time. Every folder inside app defines a URL route, and the page.tsx file inside those folders defines the UI for that route.
Starting the Development Server
To see your app in action, start the local development server:
Bashnpm run dev
Next.js will start a local server at http://localhost:3000. Open your browser and navigate to that address. You should see the default Next.js welcome page. This server includes "Fast Refresh," meaning that every time you save a file, your browser will update instantly without losing your application state.
Practice Exercise
- Open
src/app/page.tsxin your code editor. - Delete the boilerplate code inside the
<main>tag. - Replace it with a simple
<h1>Hello, World!</h1>. - Save the file and observe your browser window—the change should appear immediately.
Common Pitfalls
- Node.js Version: Next.js requires a recent Long Term Support (LTS) version of Node.js (v18.17 or later). If you get errors during installation, run
node -vto check your version. - Port Conflicts: If
localhost:3000is already in use, Next.js will automatically try to start on3001(or the next available port). Check your terminal output to confirm the address. - Case Sensitivity: In the App Router, directory names are case-sensitive and directly influence your URL structure. Always use lowercase for folder names.
Frequently Asked Questions
Q: Do I need to learn React before starting with Next.js? A: Next.js is a React framework. While you don't need to be an expert, having a basic understanding of components, props, and hooks will make this journey much smoother.
Q: Why use the App Router instead of the old Pages Router? A: The App Router is the current standard. It provides superior performance via Server Components, better data fetching patterns, and built-in support for layouts and loading states, which we will explore in later lessons like Next.js App Router: Mastering useOptimistic for Atomic Mutations.
Q: Can I change my configuration later?
A: Yes. Most configuration files (like tailwind.config.ts) can be modified at any time to suit your project's evolving needs.
Recap
You have successfully initialized a Next.js project, explored the directory structure, and launched your development server. You are now ready to start architecting your blog. As we progress, you'll see how these initial files act as the building blocks for more complex features, such as Next.js generateMetadata: Dynamic SEO for App Router.
Up next: Understanding the App Router Architecture.
Work with me

Next.js Full-Stack Web App Development
A fast, SEO-ready full-stack web app built with Next.js 16 — from idea to deployed product, by an engineer who ships to production.

Next.js E-commerce Store Development
Turn your Facebook page or small shop into a real online store — fast, mobile-first, and built to sell. Own your storefront, not just a social page.