logo

Getting Started With Next.js

By Raju Shrestha Thu Jan 01 1970

Getting Started With Next.js

Next.js is a React framework used for building modern full-stack web applications. It provides: Server-side rendering (SSR) Static site generation (SSG) API routes File-based routing SEO optimization and Fast performance.

1. What is Next.js?

Next.js is an open-source, full-stack web development framework built on top of the React JavaScript library. Created and maintained by Vercel, it provides developers with the architecture and tooling needed to build highly optimized, fast, and SEO-friendly web applications without complex manual configuration.

2. Why Use Next.js?

Next.js is used because it makes React applications faster, SEO-friendly, and easier to build and deploy.

Advantages:

  • SEO Friendly – Pages are rendered on the server (SSR), making them easily readable by search engines.
  • Fast Loading – Supports static generation (SSG) and optimized rendering for better performance.
  • Built-in Routing – File-based routing system removes the need for complex routing setup.
  • API Handling – You can create backend APIs inside the same project using API routes.
  • Image Optimization – Automatically optimizes images for faster loading and better performance.
  • Easy Deployment – Easily deploy on platforms like Vercel with minimal configuration.

3. Installation

Create a Next.js app using npm.

[@portabletext/react] Unknown block type "code", specify a component for it in the `components.types` prop

4. Project Structure

[@portabletext/react] Unknown block type "code", specify a component for it in the `components.types` prop

6. Creating Pages

Pages are created using page.js or page.jsx.

[@portabletext/react] Unknown block type "code", specify a component for it in the `components.types` prop

7. Layouts

Layouts are reusable UI wrappers.

[@portabletext/react] Unknown block type "code", specify a component for it in the `components.types` prop

8. Components

Reusable UI elements.

[@portabletext/react] Unknown block type "code", specify a component for it in the `components.types` prop

9. Client Components vs Server Components

Client Components

  • Runs in the browser (client-side)
  • Used for interactivity (useState, useEffect, events)
  • Can access browser APIs like localStorage, window
  • Marked with "use client" at the top
  • Slightly heavier because JavaScript is sent to the browser

Server Components

  • Runs on the server before sending HTML to the browser
  • Used for static content and data fetching
  • Better performance and SEO (less JS sent to client)
  • Cannot use React hooks like useState or useEffect
  • Default in Next.js App Router (no need to declare)

10. use client

Used to enable client-side interactivity.

[@portabletext/react] Unknown block type "code", specify a component for it in the `components.types` prop

11. Fetching Data

Fetch API is used in server components.

[@portabletext/react] Unknown block type "code", specify a component for it in the `components.types` prop

12. Dynamic Routes

Create dynamic pages using square brackets.

[@portabletext/react] Unknown block type "code", specify a component for it in the `components.types` prop

13. API Routes

Build backend APIs inside Next.js.

[@portabletext/react] Unknown block type "code", specify a component for it in the `components.types` prop

14. Middleware

Middleware runs before requests complete.

[@portabletext/react] Unknown block type "code", specify a component for it in the `components.types` prop

Raju Shrestha - Web Developer

Looking for a reliable web developer in Nepal? With 3+ years of experience, I specialize in building fast, secure, and scalable websites and web applications tailored to real business needs. Learn more about me and how I help businesses build future-ready digital platforms.

Date: 6/30/2026

Quick Links

  • About Me
  • Portfolio
  • Services
  • Customer Reviews
  • Contact

Contact

shrestharaju010101@gmail.com
Babarmahal, Kathmandu, Nepal
+977-9825821351

© 2026 • All Rights Reserved • Built with