logo Online Learner
  • Home
  • Learning Paths
  • Development
    Frontend Development Backend Development
  • Study Notes
  • Free Resume Builder
  • About Us
  • Contact Us
  • Login
  • Sign Up
  1. Learning Paths
  2. Next.js Tutorial
  3. Next js Data Fetching

Next.js Data Fetching

Next.js data fetching is one of the first real skills you need after learning routing and components. In the App Router, most data loading happens on the server, inside components that can be async and use await. That means your database passwords and API keys stay on the server, and your users get HTML that already contains the data.

This tutorial shows you how to fetch data in an async Server Component, query a database safely, choose between sequential and parallel requests, and stream slow sections with Suspense. You will also see how to handle errors, type the response with TypeScript, and avoid the common traps that make pages feel slow.

If you have just finished Next.js Loading & Error Handling, you already know what a loading state looks like. Now you will learn where the data actually comes from. The ideas here also connect closely to Server vs Client Components, because where you fetch changes what you can do with the result.

What Is Next.js Data Fetching in the App Router?

Next.js data fetching is the process of loading data from an API, database, or file inside a Next.js application. In the App Router, you normally fetch inside a Server Component by making the component async and using await. The data is read on the server before the page is sent to the browser, so the first HTML already includes the content .

Here is the smallest useful example. It fetches a list of users and renders their names:

// app/users/page.tsx
type User = {
  id: number;
  name: string;
  email: string;
};

export default async function UsersPage() {
  const response = await fetch("https://jsonplaceholder.typicode.com/users");
  const users: User[] = await response.json();

  return (
    <ul>
      {users.map((user) => (
        <li key={user.id}>{user.name}</li>
      ))}
    </ul>
  );
}

When you open /users, the browser receives HTML that already contains the list. There is no loading spinner on the first visit, because the server waited for the data before finishing the page. This is the default mental model for data fetching in Next.js: the server does the waiting, and the browser gets the result.

Fetch Data in an Async Server Component

An async Server Component is a component that runs only on the server and is allowed to use await. You do not need a special hook or a useEffect call. You mark the function async, call fetch with await, and return JSX.

Using fetch and await

The fetch API is the browser and Node.js function for making HTTP requests. In a Server Component, you can use it directly. The response object has a json() method, and you should give the result a type so TypeScript can check it.

// app/users/page.tsx
type User = {
  id: number;
  name: string;
  email: string;
};

export default async function UsersPage() {
  const response = await fetch("https://jsonplaceholder.typicode.com/users");

  if (!response.ok) {
    throw new Error(`Request failed with status ${response.status}`);
  }

  const users: User[] = await response.json();

  return (
    <ul>
      {users.map((user) => (
        <li key={user.id}>
          {user.name} ({user.email})
        </li>
      ))}
    </ul>
  );
}

How it works: The component is async, so Next.js waits for the promise to resolve before rendering the JSX. The response.ok check catches HTTP errors such as 404 or 500 before you try to read the body. The type User[] tells TypeScript that users is an array of objects with id, name, and email. If the API returns a different shape, TypeScript will not catch it at runtime, so the type is a promise you make to yourself and your team.

Typing the response with TypeScript

TypeScript strict mode does not know what an API returns. You write the type yourself, based on the API documentation or the actual response. Do not use any. If you are unsure, define a type with the fields you use, and add a runtime check when the data is critical.

// lib/types.ts
export type User = {
  id: number;
  name: string;
  email: string;
};

export function isUser(value: unknown): value is User {
  if (typeof value !== "object" || value === null) return false;

  const candidate = value as Record<string, unknown>;

  return (
    typeof candidate.id === "number" &&
    typeof candidate.name === "string" &&
    typeof candidate.email === "string"
  );
}

With this helper, you can check the array after parsing. A full validation library is better for large projects, but the idea is the same: TypeScript types disappear at runtime, so a real check makes the type honest.

Database Queries in a Server Component

A database query in a Server Component is safe because the code never reaches the browser. Server Components run on the server, and Next.js removes their code from the client bundle. You can import your database client, use environment variables, and run SQL or ORM calls directly .

// app/posts/page.tsx
import { db } from "@/lib/db";

type Post = {
  id: number;
  title: string;
  published: boolean;
};

export default async function PostsPage() {
  const posts: Post[] = await db
    .selectFrom("posts")
    .select(["id", "title", "published"])
    .where("published", "=", true)
    .execute();

  return (
    <ul>
      {posts.map((post) => (
        <li key={post.id}>{post.title}</li>
      ))}
    </ul>
  );
}

How it works: The database call happens on the server before the page is rendered. The browser never sees your database URL, password, or query. This is the biggest practical difference from the old Pages Router pattern, where beginners sometimes created an API route just to fetch data for a page. In the App Router, you can call the database directly from the component that needs the data .

Sequential vs Parallel Data Fetching

When a page needs more than one piece of data, the order of your await calls matters. Sequential fetching waits for one request to finish before starting the next. Parallel data fetching starts all independent requests at the same time with Promise.all. The difference can be the difference between a page that feels instant and one that feels stuck.

Sequential fetching (one after another)

// app/dashboard/page.tsx
type User = { id: number; name: string };
type Post = { id: number; title: string };

export default async function DashboardPage() {
  const userResponse = await fetch("https://jsonplaceholder.typicode.com/users/1");
  const user: User = await userResponse.json();

  const postsResponse = await fetch("https://jsonplaceholder.typicode.com/posts?userId=1");
  const posts: Post[] = await postsResponse.json();

  return (
    <div>
      <h2>{user.name}</h2>
      <p>{posts.length} posts</p>
    </div>
  );
}

Here, the second request does not start until the first one finishes. If each request takes 300 milliseconds, the page waits about 600 milliseconds. The requests do not depend on each other, so this waiting is unnecessary.

Parallel fetching with Promise.all

// app/dashboard/page.tsx
type User = { id: number; name: string };
type Post = { id: number; title: string };

export default async function DashboardPage() {
  const [userResponse, postsResponse] = await Promise.all([
    fetch("https://jsonplaceholder.typicode.com/users/1"),
    fetch("https://jsonplaceholder.typicode.com/posts?userId=1"),
  ]);

  const user: User = await userResponse.json();
  const posts: Post[] = await postsResponse.json();

  return (
    <div>
      <h2>{user.name}</h2>
      <p>{posts.length} posts</p>
    </div>
  );
}

How it works: Promise.all takes an array of promises and returns a single promise that resolves when all of them finish. Both fetch calls start at almost the same time. If each request takes 300 milliseconds, the total wait is close to 300 milliseconds, not 600. Use parallel fetching when the requests do not need each other. Use sequential fetching only when the second request needs a value from the first, such as a user ID or a slug.

Pattern When to use it Wait time Example
Sequential The second request needs data from the first Adds up Fetch artist, then fetch that artist's albums
Parallel with Promise.all Requests are independent Close to the slowest request Fetch user profile and recent posts together

Streaming Slow Parts with Suspense

Suspense is a React feature that lets you show a fallback UI while part of the page is still loading. In Next.js, you can use <Suspense> to stream a slow section without blocking the whole page. The fast parts appear immediately, and the slow part fills in when its data is ready .

// app/dashboard/page.tsx
import { Suspense } from "react";

type Post = { id: number; title: string };

async function RecentPosts() {
  const response = await fetch("https://jsonplaceholder.typicode.com/posts?_limit=5");
  const posts: Post[] = await response.json();

  return (
    <ul>
      {posts.map((post) => (
        <li key={post.id}>{post.title}</li>
      ))}
    </ul>
  );
}

export default function DashboardPage() {
  return (
    <main>
      <h1>Dashboard</h1>
      <p>This text appears immediately.</p>

      <Suspense fallback={<p>Loading recent posts...</p>}>
        <RecentPosts />
      </Suspense>
    </main>
  );
}

Browser shows: The heading and the sentence appear first. The fallback text Loading recent posts... appears in the list area. When the request finishes, the fallback is replaced by the list of posts. This is useful when one section is much slower than the rest, such as a recommendation widget or a third-party API call. You do not need to wrap every component in Suspense. Use it around the slow parts.

Fetching in Client Components and When to Avoid It

A Client Component is a component marked with "use client" that runs in the browser. You can fetch data there with useEffect or a library such as SWR or React Query, but it is usually not the first choice in the App Router .

// app/search/page.tsx
"use client";

import { useEffect, useState } from "react";

type User = { id: number; name: string };

export default function SearchPage() {
  const [users, setUsers] = useState<User[]>([]);
  const [loading, setLoading] = useState(true);

  useEffect(() => {
    async function load() {
      const response = await fetch("https://jsonplaceholder.typicode.com/users");
      const data: User[] = await response.json();
      setUsers(data);
      setLoading(false);
    }

    load();
  }, []);

  if (loading) return <p>Loading...</p>

  return (
    <ul>
      {users.map((user) => (
        <li key={user.id}>{user.name}</li>
      ))}
    </ul>
  );
}

Browser shows: First the page displays Loading.... Then the list appears after the browser makes the request. The user waits for JavaScript to load, then waits again for the data. This double wait is why client-side fetching feels slower on first visit.

When to avoid it: Do not fetch in a Client Component when the data can be fetched on the server. Server fetching gives you faster first paint, better SEO, and no API keys in the browser. Use client fetching for data that must update after user interaction, such as a live search box that calls an API as the user types. Even then, consider fetching the first result set on the server and hydrating it into the client component.

Error Handling for Failed Requests

A failed request can happen for many reasons: the API is down, the URL is wrong, or the user is offline. In a Server Component, an unhandled error stops the page from rendering. Next.js shows the nearest error.tsx boundary if you have one, or a generic error page if you do not.

// app/users/page.tsx
type User = { id: number; name: string };

export default async function UsersPage() {
  const response = await fetch("https://jsonplaceholder.typicode.com/users");

  if (!response.ok) {
    throw new Error(`Failed to load users: ${response.status}`);
  }

  const users: User[] = await response.json();

  return (
    <ul>
      {users.map((user) => (
        <li key={user.id}>{user.name}</li>
      ))}
    </ul>
  );
}

Error in production: If the request fails and there is no error.tsx file, the user sees a generic error page. If you add error.tsx in the same route segment, your custom error UI appears instead. The error message in the terminal looks like this: Error: Failed to load users: 500. Always check response.ok before calling response.json(), because a 500 response may return HTML or an empty body, and json() will throw a confusing parse error.

Are fetch Responses Cached by Default in Next.js?

No. In current Next.js versions, fetch requests are not cached by default. You must opt in with { cache: "force-cache" } if you want Next.js to store the response in its server-side cache . This is a change from older versions, where fetch was cached automatically. The official Next.js documentation on nextjs.org/docs is the best place to confirm the current default for your exact version.

// app/stats/page.tsx
type Stats = { totalUsers: number };

export default async function StatsPage() {
  const response = await fetch("https://jsonplaceholder.typicode.com/users", {
    cache: "force-cache",
  });

  const users: Stats[] = await response.json();

  return <p>Total users: {users.length}</p>;
}

How it works: Without the cache option, Next.js fetches fresh data when the route is rendered dynamically. With force-cache, Next.js looks for a matching request in its cache and returns the stored response if it is fresh. Only responses with a 200 status code are cached. If you need to refresh cached data on a schedule, use the next.revalidate option with a number of seconds.

Common Mistakes and Best Practices

  • Awaiting requests that could run in parallel. If two requests do not depend on each other, sequential await calls double your wait time. Use Promise.all when the data is independent.
  • Forgetting to check response.ok. A fetch call does not reject on HTTP errors like 404 or 500. It only rejects on network failures. If you skip the check, response.json() may throw a confusing error or return an error object that your UI tries to render.
  • Fetching user-specific data in a cached function without a user key. If you add caching later, make sure the cache key includes the user ID or session. Otherwise, one user's data can be served to another user.
  • Using any for API responses. any turns off TypeScript's checks. Define a type, even a small one, so your editor and build step can catch mistakes such as reading user.nam instead of user.name.
  • Wrapping the whole page in Suspense. Suspense works best around slow sections, not the entire page. If everything is inside one boundary, the user still waits for the slowest part before seeing anything.
  • Fetching in a Client Component when the server could do it. Server fetching avoids the extra JavaScript load and the second network request from the browser. Use client fetching only when the data must change after user interaction.

Real-World Example

This example combines the main ideas: a typed response, two independent requests with Promise.all, and a Suspense boundary around a slower section. It is a small user dashboard page.

// app/dashboard/page.tsx
import { Suspense } from "react";

type User = {
  id: number;
  name: string;
  email: string;
};

type Post = {
  id: number;
  title: string;
};

async function UserProfile() {
  const response = await fetch("https://jsonplaceholder.typicode.com/users/1");

  if (!response.ok) {
    throw new Error("Could not load user");
  }

  const user: User = await response.json();

  return (
    <section>
      <h2>{user.name}</h2>
      <p>{user.email}</p>
    </section>
  );
}

async function UserPosts() {
  const response = await fetch("https://jsonplaceholder.typicode.com/posts?userId=1");

  if (!response.ok) {
    throw new Error("Could not load posts");
  }

  const posts: Post[] = await response.json();

  return (
    <ul>
      {posts.slice(0, 5).map((post) => (
        <li key={post.id}>{post.title}</li>
      ))}
    </ul>
  );
}

export default async function DashboardPage() {
  const [user, posts] = await Promise.all([
    fetch("https://jsonplaceholder.typicode.com/users/1").then((r) => r.json() as Promise<User>),
    fetch("https://jsonplaceholder.typicode.com/posts?userId=1").then((r) => r.json() as Promise<Post[]>),
  ]);

  return (
    <main>
      <h1>Dashboard for {user.name}</h1>
      <p>You have {posts.length} posts.</p>

      <Suspense fallback={<p>Loading profile...</p>}>
        <UserProfile />
      </Suspense>

      <Suspense fallback={<p>Loading posts...</p>}>
        <UserPosts />
      </Suspense>
    </main>
  );
}

Line-by-line explanation:

  • User and Post are the TypeScript types for the two API responses. They match the fields the page uses.
  • UserProfile and UserPosts are small async Server Components. Each one fetches its own data and checks response.ok before parsing.
  • DashboardPage is also async. It uses Promise.all to start both fetches at the same time. The result is an array with the user and the posts.
  • The page renders the user's name and post count immediately, using the data from Promise.all.
  • The two <Suspense> boundaries wrap the smaller components. In this version, the data is already available from the parallel fetch, so the fallbacks may not appear. In a real app, you would remove the duplicate fetches and let the Suspense boundaries handle the slow parts independently.

Summary

  • Next.js data fetching usually happens in async Server Components. Mark the component async, use await fetch, and type the result.
  • Database queries in a Server Component are safe because the code never reaches the browser.
  • Use Promise.all for independent requests. Use sequential await only when the second request needs the first request's result.
  • Suspense lets you stream slow sections without blocking the rest of the page.
  • fetch responses are not cached by default in current Next.js. Opt in with cache: "force-cache" and check the official docs for your version.
  • Always check response.ok before calling response.json(), and avoid client-side fetching when the server can do the work.

When you need to create an API endpoint for your own data, continue with Next.js Route Handlers (API) to learn how to build request handlers in the App Router.

Frequently Asked Questions

What is the default caching behavior of fetch in Next.js?

In current Next.js versions, fetch requests are not cached by default. You must opt in by setting the cache option to force-cache. This gives you explicit control over what gets stored on the server. Older versions cached fetch automatically, so always check the documentation for your exact version .

Can I use async/await directly inside a Server Component?

Yes. Server Components can be async functions, and you can use await inside them. This is the recommended way to fetch data in the App Router. The component waits for the promise to resolve on the server, and the browser receives the finished HTML .

Should I use Promise.all or separate await calls?

Use Promise.all when the requests are independent and do not need each other's results. It starts all requests at the same time, so the total wait is close to the slowest single request. Use separate await calls only when the second request needs a value from the first, such as an ID or a slug.

When should I fetch data in a Client Component instead of a Server Component?

Fetch in a Client Component only when the data must update after user interaction, such as a live search field or a button that refreshes a list. For initial page data, a Server Component is usually better because it avoids extra JavaScript and a second network request from the browser.

How do I handle a failed fetch request in Next.js?

Check response.ok after the fetch call. If it is false, throw an Error with the status code. In a Server Component, this error will be caught by the nearest error.tsx boundary if one exists. Without a boundary, the user sees a generic error page. Checking response.ok also prevents confusing JSON parse errors.

Practice Exercises

Easy: Fetch and display a single user

Create a page at app/user/[id]/page.tsx that fetches a user from https://jsonplaceholder.typicode.com/users/1 and displays the name and email. Use a typed response and check response.ok.

Show solution
// app/user/[id]/page.tsx
type User = {
  id: number;
  name: string;
  email: string;
};

export default async function UserPage() {
  const response = await fetch("https://jsonplaceholder.typicode.com/users/1");

  if (!response.ok) {
    throw new Error("Failed to load user");
  }

  const user: User = await response.json();

  return (
    <div>
      <h2>{user.name}</h2>
      <p>{user.email}</p>
    </div>
  );
}

The component is async, checks the status, and renders typed fields.

Easy: Add a Suspense fallback

Wrap a slow component that fetches posts from https://jsonplaceholder.typicode.com/posts?_limit=3 in a <Suspense> boundary with a fallback that says Loading posts....

Show solution
// app/posts/page.tsx
import { Suspense } from "react";

type Post = { id: number; title: string };

async function Posts() {
  const response = await fetch("https://jsonplaceholder.typicode.com/posts?_limit=3");
  const posts: Post[] = await response.json();

  return (
    <ul>
      {posts.map((post) => (
        <li key={post.id}>{post.title}</li>
      ))}
    </ul>
  );
}

export default function PostsPage() {
  return (
    <main>
      <h1>Posts</h1>
      <Suspense fallback={<p>Loading posts...</p>}>
        <Posts />
      </Suspense>
    </main>
  );
}

The Suspense boundary shows the fallback while the async child component waits for data.

Medium: Use Promise.all for two requests

Fetch a user and their posts at the same time. The user URL is https://jsonplaceholder.typicode.com/users/1 and the posts URL is https://jsonplaceholder.typicode.com/posts?userId=1. Display the user's name and the number of posts.

Show solution
// app/profile/page.tsx
type User = { id: number; name: string };
type Post = { id: number; title: string };

export default async function ProfilePage() {
  const [userResponse, postsResponse] = await Promise.all([
    fetch("https://jsonplaceholder.typicode.com/users/1"),
    fetch("https://jsonplaceholder.typicode.com/posts?userId=1"),
  ]);

  const user: User = await userResponse.json();
  const posts: Post[] = await postsResponse.json();

  return (
    <div>
      <h2>{user.name}</h2>
      <p>{posts.length} posts</p>
    </div>
  );
}

Promise.all starts both fetches together, so the wait is shorter than sequential awaits.

Challenge: Add error handling and a retry button

Create a page that fetches users and shows a custom error message if the request fails. Use a Client Component with a retry button only for the error state. Keep the initial fetch in a Server Component.

Show solution
// app/users/page.tsx
import { Suspense } from "react";

type User = { id: number; name: string };

async function UserList() {
  const response = await fetch("https://jsonplaceholder.typicode.com/users");

  if (!response.ok) {
    throw new Error("Could not load users");
  }

  const users: User[] = await response.json();

  return (
    <ul>
      {users.map((user) => (
        <li key={user.id}>{user.name}</li>
      ))}
    </ul>
  );
}

export default function UsersPage() {
  return (
    <main>
      <h1>Users</h1>
      <Suspense fallback={<p>Loading users...</p>}>
        <UserList />
      </Suspense>
    </main>
  );
}
// app/users/error.tsx
"use client";

export default function UsersError({
  error,
  reset,
}: {
  error: Error & { digest?: string };
  reset: () => void;
}) {
  return (
    <div>
      <p>{error.message}</p>
      <button onClick={() => reset()}>Try again</button>
    </div>
  );
}

The Server Component throws on failure, and error.tsx provides a reset button. The retry button is a Client Component, but the data fetching stays on the server.



Shaikh Abdul Shahid
Written by Shaikh Abdul Shahid

A Full-Stack Developer with experience in PHP, Laravel, JavaScript, and React.
Founder of Online Learner, sharing practical knowledge and programming tutorials.
Building and maintaining real-world web applications since 2017.

GitLab LinkedIn
X
0 likes
Your Feedback

Help us improve by sharing your thoughts.

IT and Digital Marketing
keyboard_arrow_left Previous
Next keyboard_arrow_right
Online Learner Logo

Online Learner helps developers master programming, database concepts, interview preparation, and real-world implementation through structured learning paths.

Quick Links

  • Frontend Development
  • Backend Development
  • Learning Paths
  • Notes
  • Free Resume Builder
  • Portfolio

Company

  • About Us
  • Contact Us
  • Terms & Conditions
  • Disclaimer

© 2023 - 2026 OnlineLearner.in | All Rights Reserved.

logo
  • code Frontend
  • storage Backend
  • live_help Interviews
  • work_outline PHP Frameworks
  • settings Routine Use
  • book Blogs
Frontend
  • HTML Tutorial
    • HTML Introduction
    • HTML Tags
    • HTML Elements
    • HTML Attributes
    • HTML Heading
    • HTML Paragraph
    • HTML Formatting
    • HTML Quotations
    • HTML Comments
    • HTML Styles
    • HTML Color
    • HTML CSS
    • HTML Images
    • HTML Favicon
    • HTML Links
    • HTML DIV
    • HTML Tables
    • HTML Table Size
    • HTML Table Head
    • Table Padding & Spa...
    • Table colspan rowspsn
    • HTML Table Styling
    • HTML Colgroup
    • HTML List
    • HTML Block & Inline
    • HTML Classes
    • HTML Id
    • HTML Iframes
    • HTML Head
    • HTML Layout
    • HTML Semantic Elements
    • HTML Style Guide
    • HTML Forms
    • HTML Form Attribute
    • HTML Form Element
    • HTML input type
    • HTML Computer code
    • HTML Entity
    • HTML Symbol
    • HTML Emojis
    • HTML Charset
    • HTML Input Form Att...
    • HTML URL Encoding
  • CSS Tutorial
    • CSS Introduction
    • CSS Syntax
    • CSS Selector
    • How To Add CSS
    • CSS Comments
    • CSS Colors
    • CSS Background color
    • CSS background-image
    • CSS Borders
    • CSS Margins
    • CSS Height, Width a...
    • CSS Box Model
    • CSS Outline
    • CSS Text
    • CSS Fonts
    • CSS Icon
    • CSS Links
    • CSS Tables
    • CSS Display
    • CSS Maximum Width
    • CSS Position
    • z-index Property
  • JavaScript Tutorial
    • What is JavaScript
    • JS Syntax
    • JS Variables
    • JS Data Types
    • JS Operators
    • JS Control Flow - IF
    • JS Control Flow - S...
    • JS Control Flow - Loop
    • JS Function
    • JS Object Methods
    • JS Anonymous Funct...
    • JS Recursive Function
    • JS Default Parameters
    • JS this Keyword
    • What is an Array in...
    • What are JavaScript...
    • Error Handling in J...
    • DOM Selection in Ja...
    • DOM Traversal in Ja...
    • Manipulating Elemen...
    • Event Handling in J...
    • JavaScript Event Li...
    • JavaScript Event Pr...
    • Form Handling in Ja...
    • Dynamic Styling in ...
    • JavaScript DOM Elem...
    • Window Object in Ja...
    • What is Local Storage?
    • Regular Expressions...
  • Jquery Tutorial
    • What is jQuery?
    • Benefits of using j...
    • Include jQuery
    • Selectors.
    • Methods.
    • The $ symbol and sh...
    • Selecting elements
    • Getting and setting...
    • Adding and removing...
    • Modifying CSS and c...
    • Binding and Unbindi...
    • Common events: clic...
    • Event delegation
    • Using .on() for dyn...
    • Showing and hiding ...
    • Fading elements in ...
    • Sliding elements up...
    • .animate()
    • Understanding AJAX
    • .ajax()
    • .load(), .get(), .p...
    • Handling responses ...
    • Parent
    • Chlid
    • Siblings
    • Filtering Elements
    • Using find
    • Selecting form elem...
    • Getting form values
    • Setting form values
    • Form validation
    • Handling form submi...
    • jQuery plugins
    • Sliders plugins
    • $.each()
    • $.trim()
    • $.extend()
    • Data attributes
    • Debugging jQuery code
  • Bootstrap 4
    • What is Bootstrap
    • Benefits of using
    • Setting up
    • Container
    • Row and Column
    • Grid Classes
    • Breakpoints
    • Offsetting Columns
    • Column Ordering
    • Basic Typography
    • Text Alignment
    • Text colors
    • Backgrounds
    • Display
    • Font Size Utilities
    • Buttons
    • Navs and Navbar
    • Forms
    • Cards
    • Alerts
    • Badges
    • Progress Bars
    • Margin
    • Padding
    • Sizing
    • Flexbox
    • Dropdowns
    • Modals
    • Tooltips
    • Popovers
    • Collapse
    • Carousel
    • Images
    • Tables
    • Jumbotron
    • Media Object
  • Git
    • Understanding Versi...
    • Download and Instal...
    • Git Configure
    • Git Initialize
    • Add Changes to Staging
    • Commit Changes
    • Branching
    • Merging
    • Remote Repository
    • Understanding Git C...
    • Stashing Changes
    • Viewing Commit History
    • Undoing Changes
  • Ajax Tutorial
    • Ajax Fundamentals
    • Ajax Working
    • XMLHttpRequest Fetch
    • Synchronous vs Asyn...
    • Ajax Advantages
    • Ajax Disadvantages
    • $.ajax() method
    • Ajax GET request
    • Ajax POST Request
    • Json Response
    • Ajax Errors
    • Ajax Form
  • React Tutorial
    • What is React? Begi...
    • React Environment S...
    • React Fundamentals:...
    • Functional vs Class...
    • Props in React Expl...
    • State and setState ...
    • React Event Handling
    • React Conditional R...
    • React Lists and Keys
    • Styling in React In...
    • Styling in React Us...
    • Styling in React Us...
    • Tailwind CSS with R...
    • Tailwind vs CSS Mod...
    • React Hooks
    • React useState Hook
    • React useEffect Hook
    • React useRef Hook
    • React useContext Hook
    • React useReducer Hook
    • Custom Hooks in React
    • React Router – In...
    • Installing React Ro...
    • React Router – Ro...
    • React Router – Ne...
    • React Router URL Pa...
    • React Router Protec...
    • React Router Redire...
    • State Management in...
    • Redux State Managem...
    • Redux Toolkit Expla...
    • Redux Toolkit vs Re...
    • Controlled vs Uncon...
    • Handling Form Input...
    • API Integration in ...
    • Axios in React – ...
    • Handling Loading an...
    • Async Await in Java...
    • Displaying API Data...
    • CRUD Operations in ...
    • React Performance O...
    • React Performance O...
  • Tailwind
    • Introduction to Tai...
    • Utility-First CSS E...
    • Tailwind CSS vs Boo...
    • When and Why to Use...
    • Real-World Use Case...
    • Tailwind CSS Instal...
    • Installing Tailwind...
    • Tailwind CSS with V...
    • Setting Up Tailwind...
    • Install Tailwind CS...
    • Tailwind CSS Colors...
    • Tailwind CSS Backgr...
    • Tailwind CSS Paddin...
    • Tailwind CSS Margin...
    • Tailwind CSS Width ...
    • Tailwind CSS Height...
    • Tailwind CSS Border...
    • Tailwind CSS Border...
    • Tailwind CSS Text S...
    • Tailwind CSS Box Sh...
    • Tailwind CSS Opacit...
    • Tailwind CSS Cursor...
    • Tailwind CSS Overfl...
    • Tailwind CSS Font S...
    • Tailwind CSS Font W...
    • Tailwind CSS Text A...
    • Tailwind CSS Line H...
    • Tailwind CSS Letter...
    • Tailwind CSS Text T...
    • How to Use Google F...
    • Flexbox with Tailwi...
    • Justify Content in ...
    • Align Items in Tail...
    • Flex Direction in T...
    • Gap in Tailwind CSS...
    • Flexbox with Tailwi...
    • Grid System in Tail...
    • Grid System in Tail...
    • Responsive Design i...
    • Positioning & Z-Ind...
    • Background Colors i...
    • Background Images i...
    • Gradients in Tailwi...
    • Image Object-Fit in...
    • Image Overlay Effec...
    • Buttons in Tailwind...
    • Hover & Focus State...
    • Buttons and Forms i...
    • Cards and Sections ...
    • Navbar and Footer D...
  • TypeScript Tutorial
    • TypeScript Introduc...
    • TypeScript Installa...
    • First TypeScript Pr...
    • TypeScript Basic Types
    • Type Inference and ...
    • TypeScript Arrays a...
    • TypeScript Enums
    • TypeScript Any, Unk...
    • TypeScript Interfaces
    • Type Aliases and Un...
    • Intersection Types
    • Literal Types
    • Functions in TypeSc...
    • Classes in TypeScript
    • Access Modifiers an...
    • Abstract Classes
    • TypeScript Generics
    • TypeScript Utility ...
    • Type Guards and Nar...
    • Modules and Namespaces
    • TypeScript Decorators
    • TypeScript with React
    • TypeScript with Nod...
  • Next.js Tutorial
    • Introduction to Nex...
    • Next js Setup and P...
    • Next js App Router ...
    • Next js Pages and L...
    • Next js Navigation ...
    • Next js Dynamic Routes
    • Next js Route Groups
    • Next js Middleware
    • Server vs Client Co...
    • SSR, SSG and ISR Ex...
    • Next js Loading and...
    • Next js Data Fetching
    • Next js Route Handl...
    • Next js Forms and S...
Backend
  • PHP Tutorial
    • PHP Introduction
    • PHP Installation
    • PHP Syntax
    • PHP Comments
    • PHP Variable
    • PHP Echo
    • PHP Data Types
    • PHP Strings
    • PHP Constant
    • PHP Maths
    • PHP Number
    • PHP Operators
    • PHP if else & if el...
    • PHP Switch
    • PHP Loops
    • PHP Functions
    • PHP Array
    • PHP OOps
    • PHP Class & Object
    • PHP Constructor
    • PHP Destructor
    • PHP Access Modfiers
    • PHP Inheritance
    • PHP Final Keyword
    • PHP Class Constant
    • PHP Abstract Class
    • PHP Superglobals
    • PHP Regular Expression
    • PHP Interfaces
    • PHP Static Method
    • PHP Static Properties
    • PHP Namespace
    • PHP Iterable
    • PHP Form Introduction
    • PHP Form Validation
    • PHP Complete Form
    • PHP Date and Time
    • PHP Include Files
    • PHP - Files & I/O
    • File Upload
    • PHP Cookies
    • PHP SESSION
    • PHP Filters
    • PHP Callback Functions
    • PHP JSON
    • PHP AND Exceptions
    • PHP Connect database
  • PHP Functions
    • strlen
    • strtoupper
    • strtolower
    • ucfirst
    • ucwords
    • substr
    • str_replace
    • strpos
    • trim in php
    • explode
    • implode
    • count in php
    • array_merge
    • array_push
    • array_pop
    • array_shift
    • array_unshift
    • in_array
    • array_keys
    • array_values
    • array_filter
    • array_map
    • sort
    • asort
    • ksort
    • abs
    • round
    • ceil
    • floor
    • rand
    • mt_rand
    • max
    • min
    • pow
    • sqrt
    • date
    • time
    • strtotime
    • mktime
    • date_diff
    • getdate
    • fopen
    • fread
    • fwrite
    • fclose
    • file_get_contents
    • file_put_contents
    • file_exists
    • unlink
    • filesize
    • is_readable
    • is_writable
    • urlencode
    • urldecode
    • parse_url
    • http_build_query
    • isset
    • empty
    • is_numeric
    • is_array
    • is_string
    • filter_var
    • htmlspecialchars
    • md5
    • sha1
    • password_hash
    • password_verify
    • die
    • exit
    • var_dump
    • print_r
    • include
    • require
    • json_encode
    • json_decode
    • sleep
  • PHP and MySQL Functions
    • mysqli_connect
    • mysqli_select_db
    • mysqli_query
    • mysqli_prepare
    • mysqli_stmt_execute
    • mysqli_multi_query
    • mysqli_fetch_assoc
    • mysqli_fetch_array
    • mysqli_fetch_row
    • mysqli_fetch_object
    • mysqli_num_rows
    • mysqli_real_escape_...
    • mysqli_insert_id
    • mysqli_affected_rows
    • mysqli_error
    • mysqli_close
    • mysqli_commit
    • mysqli_rollback
  • Python Tutorial
    • What is Python?
    • Install Python on W...
    • Install Python on L...
    • Install Python on m...
    • IDE Setup
    • Python syntax
    • Python Comments
    • Python Indentation
    • Python Variables
    • Python Data Types
    • Python Numeric
    • Python Boolean
    • Python String
    • Python List
    • Python Tuple
    • Python Range
    • Python Dictionary
    • Python Arithmetic O...
    • Python Assignment O...
    • Python Comparison O...
    • Python Logical Oper...
    • Python Bitwise Oper...
    • Python if condition
    • Python if else cond...
    • Python For Loop
    • Python While Loop
    • Python break, conti...
  • MYSQL
    • SQL Introduction
    • Syntax
    • Select statement
    • Select Distinct
    • WHERE Clause
    • Order By
    • SQL AND Operator
    • SQL OR Operator
    • SQL NOT Operator
    • SQL LIKE
    • SQL IN
    • SQL BETWEEN
    • SQL INSERT INTO
    • SQL NULL Values
    • SQL UPDATE
    • SQL DELETE
    • SQL TOP, LIMIT, FET...
    • SQL MIN() and MAX()...
    • SQL COUNT() Function
    • SQL SUM()
    • SQL AVG()
    • SQL Aliases
    • SQL JOIN
    • SQL INNER JOIN
    • SQL LEFT JOIN
    • SQL RIGHT JOIN
    • SQL FULL OUTER JOIN
    • SQL Self Join
    • SQL UNION
    • SQL GROUP BY
    • SQL HAVING
    • SQL EXISTS
    • SQL ANY and ALL
    • SQL SELECT INTO
    • SQL INSERT INTO SELECT
    • SQL CASE
    • SQL NULL Functions
    • SQL Stored Procedures
    • SQL Comments
    • SQL Operators
    • SQL CREATE DATABASE
    • SQL DROP DATABASE
    • SQL BACKUP DATABASE
    • SQL CREATE TABLE
    • SQL DROP TABLE
    • SQL ALTER TABLE
    • SQL Constraints
    • SQL NOT NULL
    • SQL UNIQUE Constraint
    • SQL PRIMARY KEY
    • SQL FOREIGN KEY
    • SQL CHECK Constraint
    • SQL CREATE INDEX
    • SQL AUTO INCREMENT
    • SQL Dates
    • SQL Views
    • SQL Injection
    • SQL Hosting
    • SQL Data Types
  • Node Js
    • What is Node.js?
    • Why use Node.js?
    • Installing Node.js
    • First Node.js progr...
    • Event Loop
    • Understanding npm
    • What are Modules?
    • fs (File System)
    • Http Module
    • Path Module
    • Creating custom mod...
    • Exporting and impor...
    • Setting up a basic ...
    • Handling requests a...
    • Serving HTML
    • Serving CSS
    • Serving JavaScript
  • Python MySQL
    • Database Connection
    • Table Creation
    • Insert Query
    • Select Query
    • Update Query
    • Delete Query
    • Where Clause Query
    • Limit Clause Query
    • Join Tables
    • Order By Query
    • Group By Query
    • Aggregate Functions
    • Parameterized Query
  • Java Tutorials
    • Java Introduction
    • Java Installation
    • Java Syntax
    • Java Comments
    • Java Variables
    • Java DataTypes
    • Java Operators
    • Java Conditionals
    • Java Looping
    • Java Arrays
    • Java Methods
    • Java Classes
    • Java Objects
    • Java Constructors
    • Java Inheritance
    • Java Polymorphism
    • Java Encapsulation
    • Java Abstraction
    • Java Exception
    • Java Interfaces
    • Java File Handling
    • Java Threads
    • Java Access Modifiers
    • Java Static Keyword
    • Java Final Keyword
    • Java Nested Class
    • Java Synchronization
  • Docker
    • Introduction to Docker
    • Installing Docker
    • Docker Architecture
    • Docker Images
    • Docker Containers
    • Dockerfile Basics
    • Docker Volumes
    • Docker Networking
    • Docker Compose
    • Docker Hub & Registry
    • Multi-Stage Builds
    • Docker with Nginx
    • Docker with MySQL
    • Docker with PHP & L...
    • Docker Environment ...
    • Docker Logs & Debug...
    • Docker Security Bes...
    • Docker Swarm Basics
    • Docker vs Virtual M...
    • Real World Docker P...
Interviews
  • PHP Interviews
    • What is PHP?
    • What does PHP stand...
    • PHP Advantages
    • Difference between ...
    • Start a PHP script?
    • Commenting in PHP
    • Variable in PHP
    • Different types of ...
    • Different types of ...
    • Array in PHP
    • Difference between ...
    • Retrieve data from ...
    • PHP handle errors
    • Sessions in PHP
    • PHP Cookie
    • What are the main f...
    • What are the differ...
    • What are the differ...
  • Java Interview Questions
    • Java Basics – Wha...
    • What is the differe...
    • What are the OOP co...
    • Why is the main met...
    • What are the differ...
    • What is the differe...
    • What is Method Over...
    • What is the Differe...
    • What is the Constru...
    • What are the Access...
    • What is the this Ke...
    • What is the super K...
    • What is the static ...
    • What is the final K...
    • What is Exception H...
    • What are Checked an...
    • What is the Differe...
    • What are Multithrea...
    • What is the Java Co...
    • What is the Differe...
    • What is the Differe...
    • What is the Differe...
    • What is the Differe...
    • How Does HashMap Wo...
    • What is the Differe...
    • What is the Differe...
    • What is the String ...
    • What is the Differe...
    • What is Garbage Col...
    • What is the Differe...
    • What is a Lambda Ex...
    • What is the Stream ...
    • What are Optional C...
    • What is the Differe...
    • What are the Key Fe...
    • What is the Record ...
  • React Interviews
    • What is React.js
    • Help In Interviews
    • Features of React
    • What is JSX
    • React's Virtual DOM
    • State and Props
    • React handle data b...
    • React Component
    • setState() method.
    • Controlled Components
    • Lifecycle Methods
    • Significance of keys
    • What are the differ...
  • Laravel Interviews
    • What is Laravel?
    • What are the key fe...
    • Explain the concept...
    • What is a controlle...
    • What is Blade templ...
    • How does Eloquent O...
    • Explain the concept...
    • What are middleware...
    • How do you create a...
    • What is CSRF protec...
    • What is the purpose...
    • What is the purpose...
    • Explain the concept...
    • How do you create a...
    • What is the purpose...
    • How do you define r...
    • What are named rout...
    • Explain the use of ...
    • What is the purpose...
    • What are service pr...
  • SQL Interviews
    • What is SQL?
    • What are the differ...
    • What is the differe...
    • What is a primary key?
    • What is a foreign key?
    • What are the differ...
    • What is the differe...
    • What is the use of ...
    • What is the differe...
    • What is an index in...
    • What types of index...
    • What is a subquery?
    • How do you use the ...
    • How can you find th...
    • Explain the use of ...
    • What is a view?
    • What are the limita...
    • Write a query to fe...
    • Write a query to fe...
    • Write a query to co...
    • Write a query to fe...
    • Write a query to fe...
    • Write a query to fi...
    • Write a query to fe...
    • Write a query to re...
    • Write a query to ge...
    • Write a query to ge...
    • Write a query to li...
    • Write a query to fi...
    • Write a query to fi...
    • Write a query to ge...
    • Write a query to fi...
    • Write a query to co...
    • Write a query to fi...
    • Write a query to li...
    • Write a query to fe...
    • Write a query to fi...
    • Write a query to fe...
    • Write a query to ge...
    • Write a query to co...
    • Write a query to fe...
  • JavaScript Interview Questions
    • What Exactly is Jav...
    • What are the data t...
    • What is the differe...
    • JavaScript double e...
    • What is a Closure i...
    • What is Hoisting in...
    • Understanding "this...
    • What Are JavaScript...
    • Null vs Undefined i...
    • How Does JavaScript...
    • What is a Promise i...
    • Async/Await in Java...
    • Event Delegation in...
    • JavaScript Modules ...
    • How to Prevent a Fu...
    • JavaScript Intervie...
    • JavaScript Intervie...
    • What is bind() in J...
    • Event Bubbling vs. ...
    • Deep Copy vs Shallo...
    • What is the new Key...
PHP Frameworks
  • Laravel
    • Laravel Topics
    • Laravel 7 Installation
    • Install laravel 8
    • Laravel 8 Routing
    • Laravel Controllers
    • Views and Blade lar...
    • Database and Eloque...
    • Authentication and ...
    • CSRF Protection
    • Laravel Model
    • Database: Query Bui...
Routine Use
  • Linux
    • How to Delete a Fil...
    • Install lemp in ubu...
    • How to check packag...
    • Navigating the File...
    • Managing Files and ...
    • Viewing and Editing...
    • Managing Processes ...
    • Scheduling Tasks wi...
    • Disk Usage Analysis...
    • File and Directory ...
Blogs
  • Blogs
    • Free Hosting on AWS...
    • PHP 8.6 Partial Fun...
    • What is SEO?
    • Zoho Free Mail
    • Speed Up Your Appli...
    • What is a JavaScrip...
    • Laravel vs Lumen: T...
    • MySQL vs PostgreSQL...
    • Automate Free MySQL...
    • How to Use Google A...
    • What is n8n?
    • Cloud Platform Comp...
    • Top Common Mistakes...
    • PHP 8.5: The Pipeli...
    • Google Antigravity ...
    • How to Optimize Que...
    • React vs Angular vs...
    • Base44: Features, P...
    • Difference Between ...
    • HTTP Status Codes E...
    • Build Native Mobile...
    • Top 10 JavaScript F...
    • JIRA, Waterfall, an...
    • WebSockets in Moder...
    • A Complete Real-Wor...
    • Why Developers Shou...
    • Service-Based Compa...
    • Bootstrap vs Tailwi...
    • Direct Prompt vs St...
    • Top 25 SEO HTML Tag...
    • Docker Commands Che...
    • Authentication vs A...
    • Top AI Portals in 2...
    • What is Replit? Com...
    • Laravel 13 Released...
    • NEET Paper Leak Pre...