Menu Close

CRUD


React

CRUD Demo

A Simple CRUD Application Demo Using React With Typescript!

๐Ÿš€ Live Demo

โฉ Table of contents

๐Ÿ“– About the Project

CRUD is a starter template that provides a comprehensive setup for building a web app using the React.js and vite.js framework. Don’t worry about the configuration ๐Ÿ”จ this template will take care of that, focus on your codesโŒจ๏ธ and project ideas๐Ÿ’ก

The application allows users to create, read, update, and delete data records in mockAPI.io. The user interface is built using React. This template give you the end to end type safety. Additionally, it includes a range of popular libraries and tools, such as Prettier, ESLint, and Tailwind CSS, to ensure that the code is well-formatted and follows best practices.

๐Ÿ” Features

  • ๐Ÿ“ฑ Responsive UI with Tailwindcss
  • ๐ŸŽฏ Make Development simple
  • ๐Ÿž Vscode debugging
  • ๐Ÿ”ฅ Hot Module Replacement(HMR)
  • ๐Ÿ’ช Eslint, Prettier and Airbnb make your code stronger
  • ๐Ÿ–ฅ Build your application for multi-platform

๐Ÿ›  Built With

CRUD Built With











๐Ÿƒโ€โ™‚๏ธ Getting Started

These instructions will get you a copy of the CRUD and running on your local machine for development and testing purposes. See Deploy for notes on how to lunch your PWA app in live.

๐Ÿ“š Before You Begin

Before you begin i recommend you read about the basic building blocks that assemble a CRUD:

๐Ÿ–ฅ๏ธ Prerequisites

Make sure you have installed all of the following prerequisites on your development machine:

NOTE: This project requires NodeJS (version 14 or later) and NPM.
Node and NPM are really easy to install.

๐Ÿ›ซ Quick Start

There are several ways you can get the CRUD:

๐ŸŒ€ Cloning The GitHub Repository

The recommended way to get CRUD is to use git to directly clone the repository:

# Clone the project git clone https://github.com/AjayKanniyappan/CRUD.git <your-project-name> # Enter the project directory cd <your-project-name>

This will clone the latest version of the CRUD repository to a CRUD folder.

๐Ÿ—ƒ๏ธ Downloading The Repository Zip File

Another way to use the CRUD is to download a zip copy from the main branch on GitHub. You can also do this using the wget command:

wget https://github.com/AjayKanniyappan/CRUD/archive/refs/heads/main.zip -O CRUD.zip; unzip CRUD.zip; rm CRUD.zip

Don’t forget to rename CRUD-main after your project name.

๐Ÿงฐ Quick Install

Once you’ve downloaded the Template and installed all the prerequisites, you’re just a few steps away from starting to develop your CRUD Web App using React.js.

The Template comes pre-bundled with a package.json file that contain the list of modules you need to start your application.

To install the dependencies, run this in the application folder from the command-line:

# Install dependency
npm install

Or if you prefer using Yarn:

# Install dependency
yarn install

This command does a few things:

  • First it will install the dependencies needed for the application to run.
  • If you’re running in a development environment, it will then also install development dependencies needed for testing and running your application.

๐Ÿ“‚ Directory Structure

CRUD files and folder structure.

+โ”œโ”€โ”€ .husky                       Automate your git commits
 โ”œโ”€โ”€ .dist                        Contains the minimized version of the source code
+โ”œโ”€โ”€ .vscode                      vscode debug folder and extension support
 โ”‚
+โ”œโ”€โ”€ public                       Project assets folder
 โ”‚   โ””โ”€โ”€ NxN.svg                  Contains icons and logos
 โ”‚
+โ”œโ”€โ”€ src                          Source code folder
 โ”‚   โ”œโ”€โ”€ components               This folder consists of a collection of UI components
 โ”‚   โ”œโ”€โ”€ constants                It contains constant urls and data
 โ”‚   โ”œโ”€โ”€ hooks                    It contains custom hooks for all pages
 โ”‚   โ”œโ”€โ”€ layouts                  It contains page layout
 โ”‚   โ”œโ”€โ”€ services                 It contains API Services
 โ”‚   โ”œโ”€โ”€ styles                   It contains css styles
 โ”‚   โ”œโ”€โ”€ svg                      It contains SVG Vectors
 โ”‚   โ”œโ”€โ”€ types                    Typescript types declaration folder
 โ”‚   โ”œโ”€โ”€ App.tsx                  It contains Components and Routes
 โ”‚  +โ””โ”€โ”€ main.tsx                 Starting point of the application
 โ”‚
 โ”œโ”€โ”€ .editorconfig                EditorConfig for defining coding styles
 โ”œโ”€โ”€ .eslintrc.json               Eslint configurations
 โ”œโ”€โ”€ .prettierrc                  prettier code formatter
+โ”œโ”€โ”€ index.html                   index path
+โ”œโ”€โ”€ package.json                 Package.json for development
 |โ”€โ”€ postcss.config.js            Post CSS configurations
+โ”œโ”€โ”€ tailwind.config.js           Tailwind CSS configurations
 โ”œโ”€โ”€ tsconfig.json                TypeScript Configuration
+โ”œโ”€โ”€ tsconfig.node.json           TypeScript paths
+โ””โ”€โ”€ vite.config.ts               Vite and React.js configurations

๐Ÿ‘จโ€๐Ÿ’ป Starting Development

Use your favorite JavaScript Package Managers npm or yarn or pnpm

๐Ÿƒ Running Your Application

Run your application using npm:

npm run dev

Or if you prefer using Yarn:

yarn dev

Your React.js application should run on port 5050 with the development environment configuration, so in your browser just go to http://localhost:5050

That’s it! Your application should be running. To proceed with your development, check the other sections in this documentation. If you encounter any problems, Feel free to check issues page.

๐Ÿ›ฌ Change Port Number

If the localhost 5050 port number already in use! or if you like to change your React.js application number.

Go to ๐Ÿ‘‰ package.json and change the port number 5050 to your-port-number

port

๐Ÿ†š Vscode Debugging

This guide goes over how to start VSCode debugging your React.js Project.

you can easily debug this CRUD.

To bring up the Run and Debug view, select the Run and Debug icon in the Activity Bar on the side of VS Code. You can also use the keyboard shortcut Ctrl+Shift+D.

Click the button or press F5 to start debugging

๐Ÿงน Clean Cache

If you want clean the cache files and node_modules cache run this below command ๐Ÿ‘‡:

npm run clean

NOTE: It will remove your node_module folder, build files and env files.

๐Ÿ’ˆ Style your Code

The CRUD has Eslint, Prettier and Airbnb Configurations, this will help you to Style your code and syntax check and more.

Eslint will check syntax, find problems, and enforce code style of your code.

Prettier will format your code style.

All you have to do is run this below command ๐Ÿ‘‡:

npm run lint

NOTE: This command show you the warnings and errors in your code.

๐Ÿ›ฐ๏ธ Git Commits

Automate your Git commits using Husky, and don’t commit or push the bad code in git.

Husky improves your commits and more, You can use it to lint your commit messages, run tests, lint code, etc… when you commit or push. Husky supports all Git hooks.

Run below command ๐Ÿ‘‡ to prepare Husky:

npm run prepare

See docs and more about Husky.

That’s it! Your application should be running. To proceed with your development, check the other sections in this documentation. If you encounter any problems, Feel free to check issues page.

๐Ÿšข Deploy your own

Congratulations, you are ready to deploy your CRUD to production. This document will teach how to deploy vercel or self-hosted.

๐Ÿ”ผ Vercel

The easiest way to deploy React.js to production is to use the Vercel platform developed by the creators of React.js.

NOTE: If you want to read more about vercel, kindly read this ๐Ÿ™ Documentation.

๐Ÿ‘ป Self-Hosting

CRUD can be deployed to any hosting provider that supports Node.js.

If youโ€™ve followed the instructions so far, your package.json should have the following build and start scripts:

"scripts": {
    "build": "tsc && vite build",
    "clean": "git clean -dfX",
    "dev": "vite --port 5050",
    "lint": "eslint --fix --max-warnings 0 .",
    "prepare": "husky install",
    "start": "npm run build && vite preview --port 5050"
  }
npm run build

In your own hosting provider, run the build script once, which builds the production application in the .dist folder.

After building, the start script starts a Node.js server that supports hybrid pages, serving both statically generated and server-side rendered pages, and API Routes.

npm run start

NOTE: If you want to read more about deployment, kindly read this ๐Ÿ™ Documentation.

๐Ÿ› ๏ธ Author

๐Ÿ‘จโ€๐Ÿ’ป Ajay Kanniyappan

๐Ÿ“ License

MIT License ยฉ Ajay Kanniyappan

View Source Code
Posted in Development