Getting Started with Next.js

A beginner’s guide to building modern web apps with Next.js - from a self-taught developer’s perspective.

Feb 1, 2025by Humza Hussain
Next.js
React
TypeScript

Introduction

Next.js is a powerful React framework that brings server-side rendering (SSR) and static site generation (SSG) to the table, making it a go-to choice for developers building modern, performant web applications. As a self-taught developer, I’ve found Next.js to be an incredible tool for creating fast, scalable, and SEO-friendly apps without drowning in configuration headaches. In this guide, I’ll walk you through the essentials of getting started with Next.js, sharing insights from my own journey of learning and experimenting with this framework. Whether you’re just dipping your toes into web development or looking to improve your skills, this post will give you a solid foundation to kick off your Next.js adventure.

We’ll cover everything from setting up your first project to exploring its standout features, all explained in a way that cuts through the jargon and gets to the heart of why Next.js is worth your time. Let’s dive in!

Setting up your project

Starting a Next.js project is refreshingly simple, even if you’re new to the ecosystem. Open your terminal and run these commands to get up and running:

Here’s what’s happening: `npx create-next-app@latest my-next-app` scaffolds a new project with all the necessary files and dependencies. The `cd my-next-app` command moves you into the project folder, and `npm run dev` fires up the development server. Head to `http://localhost:3000` in your browser, and voilà—you’ll see the default Next.js welcome page! From here, you can start tweaking files in the `pages` directory to see your changes reflected instantly thanks to Next.js’s hot reloading.

Pro tip: If you prefer TypeScript (and I recommend you give it a go for better code safety), add the `--typescript` flag when creating your app: `npx create-next-app@latest my-next-app --typescript`. It’s a small step that pays off big time as your projects grow.

npx create-next-app@latest my-next-app
cd my-next-app
npm run dev

Key Features

Next.js isn’t just another React framework—it’s packed with features that streamline development and boost performance. Here’s a rundown of what makes it shine, based on my hands-on experience:

These features aren’t just buzzwords—they solve real problems. SSR and SSG let you optimise for speed and search engine visibility, whilst file-based routing eliminates the need for messy routing libraries. API routes are a game-changer for prototyping backend logic without spinning up a separate server. For a self-taught dev like me, this all adds up to a framework that’s approachable yet powerful enough to scale with your ambitions.

  • **Server-Side Rendering (SSR):** Pages render on the server, delivering fully-formed HTML to the browser for faster first loads and better SEO. Perfect for content-heavy sites like blogs or e-commerce platforms.
  • **Static Site Generation (SSG):** Pre-render pages at build time, serving static files that load lightning-fast and scale effortlessly. Think landing pages or documentation sites.
  • **File-based Routing:** Drop a file like `about.js` into the `pages` directory, and it’s instantly a route (`/about`). No config, no fuss—just pure simplicity.
  • **API Routes:** Need a quick backend? Create a file in `pages/api`, and you’ve got a serverless endpoint. I’ve used this for contact forms and data fetching without leaving my Next.js app.

Why Next.js?

So, why did Next.js click for me? It’s the sweet spot between simplicity and control. Setting up a React app from scratch means wrestling with Webpack, Babel, and SSR configs—Next.js handles all that out of the box, letting you focus on building. But it’s not a straitjacket; you can still customise everything when you’re ready to dig deeper. The community is another huge win—tons of tutorials, plugins, and the official docs are gold for solo learners like me.

This is just the start! In future posts, I’ll dive into practical stuff like building dynamic pages, fetching data with `getStaticProps` and `getServerSideProps`, and deploying your app to platforms like Vercel (the folks behind Next.js). Stick around if you want to improve your web dev game!