Once the project has been cloned, navigate to the application directory and run the command yarn or npm i to install all dependencies. For example:
cd simple-auth-app/
yarnAt this point, you can test the correct execution of your application. If you are using Yarn, run the following command:
yarn run dev- axios: Library for making HTTP requests.
- eslint-plugin-react-hooks: Helps catch errors and provides guidance when coding hooks.
- redux: State management library for the application.
- sass: Enables the use of SASS instead of plain CSS (if you install this extension, make sure to change your file extensions from
.cssto.scssand update the import paths inApp.tsxandmain.tsxaccordingly). - bootstrap: CSS framework.
- react-hook-form: Library for handling and validating forms.
- react-router-dom: Routing library for React.
In my projects, I usually follow this directory structure:
├── src/
├── assets/
│ ├── images/
│ ├── icons/
│ ├── fonts/
│ ├── ...
├── components/
│ └── Component1.component.tsx
├── data/
├── hooks/
├── layout/
├── models/
├── pages/
│ └── page1/
│ ├── components/
│ └── Page1.page.tsx
├── redux/
│ ├── ...
│ ├── store.tsx
├── routes/
│ ├── routes.tsx
├── services/
├── utilities/
...
├── App.scss
├── App.tsx
├── favicon.ico
├── index.scss
└── main.tsx
...
- The
assetsdirectory contains all multimedia resources such as images, fonts, and icons. It can also include files for application internationalization in ani18nsubdirectory. - The
componentsdirectory contains all global components of your application, such as custom alerts, loaders, or pagination components. - The
datadirectory holds constants that can be used across your application, such as routes or enumerations. - The
hooksdirectory contains custom hooks that abstract logic from your application. - The
layoutdirectory contains the main elements of your application, typically including four parts: Header, Sidebar, Footer, and Skeleton. - The
modelsdirectory contains the models used in your application. Since we are using TypeScript, it is essential to maintain proper typing throughout the application. - The
pagesdirectory holds the pages of your application. I usually create a subdirectory for each set of related pages (e.g., ausersdirectory would containUsersList.page.tsx,UsersCreate.page.tsx, andUserDetails.page.tsx). Additionally, you can create acomponentssubdirectory for shared components among these pages. - The
reduxdirectory contains the global state configuration for your application, which will be discussed later. - The
routesdirectory contains a file defining the application routes. - The
servicesdirectory holds the axios configuration for HTTP requests, where you can add interceptors to include headers or handle errors better. - Finally, the
utilitiesdirectory is used for storing global utility functions, such as currency conversion or date formatting functions.
Currently, this project includes a simple (fake) login system using localStorage. It can be extended to use an authentication API.
- Website - www.bryan-aguilar.com
- Medium - baguilar6174
- LinkedIn - baguilar6174