Introduction

Building a full-stack CRUD (Create, Read, Update, Delete) application is a core skill in modern web development. If you understand CRUD, you understand how real-world apps like e-commerce platforms, dashboards, and admin panels work.

In this article, we will build a simple and practical CRUD application using React (frontend) and Node.js with Express (backend). We will keep everything in simple words so beginners can follow easily.

SEO Keywords: React CRUD App, Node.js CRUD API, Full Stack Development, MERN Stack Basics, REST API Tutorial

What is CRUD

CRUD stands for four basic operations that every application performs:

Real-life example: Think of a to-do app:

Architecture Overview

In a full-stack application, frontend and backend work together:

Flow in simple words:

  1. User clicks a button in React

  2. React sends a request to backend

  3. Backend processes request

  4. Backend sends response

  5. React updates UI

This is the core of full-stack development.

Backend Setup using Node.js and Express

First, we create a simple Express server:

const express = require("express");
const app = express();

app.use(express.json());

let items = [];

Here:

Create Operation (POST API)

This API adds new data:

app.post("/items", (req, res) => {
  items.push(req.body);
  res.send("Item Added");
});

Explanation in simple words:

Read Operation (GET API)

This API fetches all data:

app.get("/items", (req, res) => {
  res.json(items);
});

Explanation:

Update Operation (PUT API)

This API updates existing data:

app.put("/items/:id", (req, res) => {
  const id = req.params.id;
  items[id] = req.body;
  res.send("Item Updated");
});

Explanation:

Delete Operation (DELETE API)

This API removes data:

app.delete("/items/:id", (req, res) => {
  const id = req.params.id;
  items.splice(id, 1);
  res.send("Item Deleted");
});

Explanation:

Frontend Setup using React

Now we connect React with backend:

import { useEffect, useState } from "react";

function App() {
  const [items, setItems] = useState([]);

Read Data in React (GET Request)

useEffect(() => {
  fetch("/items")
    .then(res => res.json())
    .then(setItems);
}, []);

Explanation:

Create Data in React (POST Request)

const addItem = async () => {
  await fetch("/items", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ name: "Item 1" })
  });
};

Explanation:

Update Data in React (PUT Request)

const updateItem = async (id) => {
  await fetch(`/items/${id}`, {
    method: "PUT",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ name: "Updated Item" })
  });
};

Delete Data in React (DELETE Request)

const deleteItem = async (id) => {
  await fetch(`/items/${id}`, {
    method: "DELETE"
  });
};

Simple UI Example

return (
  <div>
    <button onClick={addItem}>Add Item</button>

    {items.map((item, index) => (
      <div key={index}>
        {item.name}
        <button onClick={() => updateItem(index)}>Update</button>
        <button onClick={() => deleteItem(index)}>Delete</button>
      </div>
    ))}
  </div>
);

Step-by-Step Flow

  1. User clicks button

  2. React sends API request

  3. Express handles request

  4. Data is updated in server

  5. Response is sent back

  6. React updates UI automatically

Real-World Use Case

Example: E-commerce website

This is exactly how real applications work.

Advantages of Full CRUD App

Disadvantages

Best Practices

Summary

In this article, we learned how to build a full CRUD application using React and Node.js with a REST API. We covered Create, Read, Update, and Delete operations with simple examples and real-world use cases. Understanding CRUD is essential for full-stack development and is widely used in modern web applications. Once you are comfortable with this, you can extend it by adding a database, authentication, and deploying your app to production.