Basic NestJS For Absolute Beginners
Getting Started with NestJS: A Beginner-Friendly Tutorial
NestJS is a progressive Node.js framework for building efficient and scalable server-side applications. Think of it as a backend version of Angular—structured, modular, and powerful.
If you know some basic JavaScript or TypeScript and you're comfortable with Node.js/Express, NestJS will feel like a well-organized upgrade.
🧰 Prerequisites
Before starting, make sure you have:
Node.js (v16 or above): https://nodejs.org
npm or yarn
Basic knowledge of JavaScript or TypeScript
Familiarity with REST APIs and Express is a plus
📦 Step 1: Install the Nest CLI
The Nest CLI is the easiest way to generate a new project and components.
⚙️ Step 2: Create Your First Project
Generate a new NestJS project using the CLI:
You’ll be asked to choose a package manager — choose npm or yarn.
Once the installation is done:
Open your browser and visit:
👉 http://localhost:3000
You should see:Hello World!
🏗️ Step 3: Understand the Project Structure
NestJS uses modules, controllers, and services.
Here’s the core structure you’ll see:
🧱 Step 4: Create Your First Module
Let’s say you want to create a simple cats feature.
This creates cats/cats.module.ts.
🎮 Step 5: Create a Controller and Service
This gives you:
Update cats.controller.ts to look like this:
Update cats.service.ts:
Now go to:
👉 http://localhost:3000/cats
And you'll get a list of cats!
Add a POST Route
In cats.controller.ts:
In cats.service.ts:
Use Postman or curl:
What Next?
Explore DTOs and Validation with
@nestjs/class-validatorConnect a database using
@nestjs/typeormor@nestjs/mongooseUse Guards, Pipes, and Interceptors for advanced use cases
Add authentication with Passport and JWT
Resources
Official docs: https://docs.nestjs.com
CLI docs: https://docs.nestjs.com/cli/overview
Example projects: https://github.com/nestjs/nest
Recap
NestJS gives you a full toolbox to write clean, testable, and enterprise-grade APIs with Node.js. You’ve just built your first NestJS app with a custom controller, service, and route!
Keep building from here—NestJS is massive, but beginner-friendly with the right steps.
Getting started
main.ts (engine startup/entry point)
app.module.ts = main module/root module: specifies imports, controllers and providers (services)

