example_store_react Tailwind Templates

Example_store_react

Store app with React and Tailwind; features login, protected routes, product browsing, and API integration.

Example Store App

This project is part of my frontend learning portfolio focused on React and Tailwind CSS.

A responsive store application built with React, Vite, and Tailwind CSS. This app allows users to log in, view a list of products, and access detailed views of each product. It demonstrates a complete login flow with form validation, protected routes, and toast notifications. The project integrates the API from dummyjson.com to simulate user authentication and manage product data. Built as a practice exercise, this app offers an example of how to implement a simple store with user authentication and product browsing functionality.


šŸ“‘ Table of Contents


Project Structure

react-login/
ā”œā”€ā”€ public/               # Public static files
ā”œā”€ā”€ src/                  # Main source code
│   ā”œā”€ā”€ api.js            # Mock API logic
│   ā”œā”€ā”€ assets/           # Resource files (images)
│   ā”œā”€ā”€ components/       # Reusable components
│   ā”œā”€ā”€ hooks/            # Custom React hooks
│   ā”œā”€ā”€ layouts/          # Layout structures
│   ā”œā”€ā”€ pages/            # Main pages of the app
│   ā”œā”€ā”€ index.css         # Global styles for app
│   ā”œā”€ā”€ main.jsx          # React entry point
ā”œā”€ā”€ index.html            # Main HTML file
ā”œā”€ā”€ package.json          # Dependencies and scripts
ā”œā”€ā”€ tailwind.config.js    # Tailwind CSS configuration
ā”œā”€ā”€ postcss.config.cjs    # PostCSS configuration
ā”œā”€ā”€ vite.config.js        # Vite configuration
└── README.md             # Project documentation

Features

  • Protected routes
  • Form validation with react-hook-form
  • Session persistence with localStorage
  • Toast notifications using sonner
  • Responsive design with Tailwind CSS

Installation

  1. Clone the repository:

    git clone https://github.com/LSCasas/react-login.git
    cd react-login
    
  2. Install dependencies:

    npm install
    

How to Use This Project

Start the development server:

npm run dev

Then, open your browser and navigate to :

http://localhost:5173


Authentication

Login Process:

To log in, use the credentials of a sample user from the API — for example:

Username: emilys
Password: emilyspass

If the credentials are incorrect, the app will show the following:

  • A toast notification with the message: "Incorrect username or password."
  • An inline error message within the form that says: "Invalid credentials."

Security Note:

User session data is stored in localStorage for simplicity. In a production environment, this is not recommended due to security risks like XSS attacks. For better security, use HttpOnly cookies to store tokens. Since this is a portfolio project and not handling real sensitive data, these security measures are not fully implemented.

Requirements

  • Node.js >= 18
  • npm

Contribution

If you want to contribute to this project, follow the steps below:

  1. Fork the repository.

  2. Create a new branch for your feature:

    git checkout -b feature/new-feature
    
  3. Make your changes.

  4. Commit your changes:

    git commit -am 'Add new feature'
    
  5. Push your changes to your fork:

    git push origin feature/new-feature
    
  6. Create a Pull Request for your changes to be reviewed and merged into the main project.


Learn More

To learn more about the tools and libraries used in this project, check out the following resources:

Your feedback and contributions to this project are welcome!

Top categories

Loading Svelte Themes