An open API service indexing awesome lists of open source software.

https://github.com/marwanm-dev/tanstack-crud


https://github.com/marwanm-dev/tanstack-crud

Last synced: 4 months ago
JSON representation

Awesome Lists containing this project

README

          

# React + Vite + TypeScript CRUD App

This is a modern CRUD application built using **React**, **Vite**, and **TypeScript** with full integration of **Redux Toolkit**, **TanStack Query**, **TanStack Table**, **Axios**, and **Tailwind CSS v4**. It fetches post data from `jsonplaceholder.typicode.com`, stores it in Redux, and supports full Create, Read, Update, and Delete operations.

---

## โš™๏ธ Tech Stack

* **Frontend**: React, TypeScript, Vite
* **State Management**: Redux Toolkit
* **Server State Handling**: TanStack Query
* **Table Rendering**: TanStack Table v8
* **HTTP Client**: Axios
* **Styling**: Tailwind CSS v4

---

## ๐Ÿ“ Folder Structure

```
.
โ”œโ”€โ”€ app/
โ”‚ โ””โ”€โ”€ store.ts
โ”œโ”€โ”€ components/
โ”‚ โ”œโ”€โ”€ Modal.tsx
โ”‚ โ””โ”€โ”€ Table.tsx
โ”œโ”€โ”€ features/
โ”‚ โ””โ”€โ”€ posts/
โ”‚ โ”œโ”€โ”€ PostForm.tsx
โ”‚ โ”œโ”€โ”€ PostView.tsx
โ”‚ โ”œโ”€โ”€ postsAPI.ts
โ”‚ โ”œโ”€โ”€ postsSlice.ts
โ”‚ โ””โ”€โ”€ types.ts
โ”œโ”€โ”€ hooks/
โ”‚ โ”œโ”€โ”€ useAppDispatch.ts
โ”‚ โ”œโ”€โ”€ useAppSelector.ts
โ”‚ โ””โ”€โ”€ usePostsData.ts
โ”œโ”€โ”€ lib/
โ”‚ โ””โ”€โ”€ axiosInstance.ts
โ”œโ”€โ”€ utils/
โ”‚ โ””โ”€โ”€ getMEX.ts
โ””โ”€โ”€ main.tsx / App.tsx
```

---

## ๐Ÿš€ Features

* Fetch posts using TanStack Query and cache data.
* Store and manipulate posts in Redux state.
* Perform Create, Read, Update, Delete (CRUD) operations.
* Show posts in a fully sortable and searchable table.
* Generate the smallest available ID (Mex) for new posts.
* Responsive, styled UI with Tailwind CSS v4.

---

## ๐Ÿง  Concepts Demonstrated

* Decoupling server state (TanStack Query) from global app state (Redux).
* Custom reusable hooks (`usePostsData`, `useSortedFilteredPosts`, `useAppDispatch`, etc).
* Dynamic table rendering with sorting/search.
* Controlled components with trimmed input values.
* Conditionally showing scrollbars based on content height.
* Efficient modal UI for editing/creating posts.

---

## ๐Ÿ“ Setup Instructions

1. **Clone this repo**

```bash
git clone https://github.com/your-username/your-repo-name.git
cd your-repo-name
```

2. **Install dependencies**

```bash
npm install
```

3. **Run the development server**

```bash
npm run dev
```

---

## ๐Ÿงช Notes

* Data comes from the fake REST API: [jsonplaceholder.typicode.com](https://jsonplaceholder.typicode.com/posts)
* MEX (Minimum Excluded Value) ensures unique post IDs even when posts are deleted.

---

## Live Demo

* https://tanstack-crud-flame.vercel.app/

---