shopcart-react-vite-ecommerceshopcart-firebase-storefrontreact-shopcart-bootstrap-store
Description:
Modern, responsive e‑commerce web application built with React 18, Vite, React Router, Firebase Authentication, Bootstrap 5 / React-Bootstrap, and Swiper, featuring product catalog browsing, category filtering, search, pagination, shopping cart with localStorage persistence, and a blog section—perfect as a production-ready storefront starter or a learning project for full-stack React e‑commerce.
ShopCart is a modern, responsive e‑commerce web application built with React 18, Vite, React Router, Firebase Authentication, Bootstrap 5 / React-Bootstrap, and Swiper.
It provides a full shopping experience with product listing, category filtering, search, pagination, cart management with localStorage persistence, protected checkout flow, and a simple blog section.
-
Modern Single Page Application
- React 18 + Vite for fast development and optimized builds.
- Client-side routing with React Router.
-
E-commerce Functionality
- Product listing powered by local JSON data.
- Category-based filtering and search.
- Grid/List toggle view for products.
- Pagination on the shop page.
- Shopping cart stored in
localStoragewith quantity updates and totals. - Shipping cost and order total calculation.
-
Authentication & Authorization
- Firebase Authentication integration.
- Email/password sign up & login.
- Google sign-in via Firebase (configurable).
- Protected routes with
PrivateRoute(e.g., cart/checkout).
-
Content & UI
- Home page hero/banner, category showcases, about, and sponsor sections.
- Blog and single blog post pages.
- Reusable layout components and page headers.
- Responsive design using Bootstrap 5 and React-Bootstrap.
- Icon fonts and animations via custom asset CSS.
-
Developer Experience
- Vite dev server with hot module replacement.
- ESLint configuration for React.
- Environment-based Firebase configuration via
import.meta.env.
-
Frontend
- React 18
- Vite
- React Router DOM
- React-Bootstrap / Bootstrap 5
- Swiper
- React CountUp
- Icofont + custom CSS for animations and styling
-
Authentication & Services
- Firebase (Authentication; extensible to other Firebase services)
-
State & Storage
- React hooks (
useState,useEffect,useContext) localStoragefor cart persistence
- React hooks (
-
Tooling
- ESLint (React, React Hooks, React Refresh plugins)
graph LR
%% Core layers
User["User"]
ReactApp["React App"]
ReactRouter["React Router"]
PrivateRoute["PrivateRoute"]
LocalCart["LocalStorage Cart State"]
FirebaseAuth["Firebase Auth Service"]
%% Pages and routes
HomePage["Home"]
ShopPage["Shop"]
BlogPage["Blog"]
CartPage["Cart Protected"]
CheckoutPage["Checkout Protected"]
%% User to app
User --> ReactApp
%% App and routing
ReactApp --> ReactRouter
%% Public routes
ReactRouter --> HomePage
ReactRouter --> ShopPage
ReactRouter --> BlogPage
%% Protected route flow
ReactRouter --> PrivateRoute
PrivateRoute --> CartPage
PrivateRoute --> CheckoutPage
%% Auth for protected routes
PrivateRoute --> FirebaseAuth
ReactApp --> FirebaseAuth
%% Cart state in LocalStorage
ReactApp --> LocalCart
CartPage --> LocalCart
CheckoutPage --> LocalCart
%% User interaction with main sections
User --> HomePage
User --> ShopPage
User --> BlogPage
User --> CartPage
User --> CheckoutPage
Paths are indicative; adjust if your structure differs.
index.html– Root HTML template used by Vite.src/main.jsx– App entry point; sets up React, React Router, andAuthProvider.src/App.jsx– Root layout and route outlet.src/home/– Home page sections (Banner,HomeCategory,CategoryShowCase, etc.).src/shop/Shop.jsx– Product listing page (filtering, pagination, grid/list view).SingleProduct.jsx– Individual product details.CartPage.jsx– Cart management and checkout box.CheckOutPage.jsx,ProductCard.jsx,Pagination.jsx, filters, sidebar components, etc.
src/blog/Blog.jsx– Blog listing.SingleBlog.jsx– Single blog details.
src/about/,src/contact/– Static informational pages.src/components/PageHeader.jsx,Login.jsx,SignUp.jsx, and other reusable components.
src/contexts/AuthProvider.jsx– Auth context and Firebase auth integration.src/privateRoute/PrivateRoute.jsx– Route guard for protected pages.src/firebase/firebase.config.js– Firebase app initialization.src/products.json– Local product data source.src/assets/– Images, icons, and CSS (icofont,animate.css,style.min.css).
- Node.js ≥ 18 (recommended)
- npm, yarn, or pnpm
git clone https://github.com/<your-username>/shopcart-react-vite-ecommerce.git
cd shopcart-react-vite-ecommerce(Replace the repo URL and folder name with whichever name you choose.)
Using npm:
npm installOr with yarn:
yarnCreate a .env file in the project root (same level as package.json) and add your Firebase config:
VITE_APIKEY=your_api_key
VITE_AUTHDOMAIN=your_auth_domain
VITE_PROJECTID=your_project_id
VITE_STORAGEBUCKET=your_storage_bucket
VITE_MESSAGINGSENDERID=your_messaging_sender_id
VITE_APPID=your_app_idThese are referenced in src/firebase/firebase.config.js via import.meta.env.
npm run devVite will start a local dev server (by default on http://localhost:5173 or similar).
Open the URL in your browser to view the app.
npm run buildThis outputs an optimized production build to the dist directory.
npm run previewFrom package.json:
npm run dev– Start the Vite development server.npm run build– Build the app for production.npm run preview– Preview the production build locally.npm run lint– Run ESLint on the project.
/– Home page (banner, featured categories, marketing sections)./shop– Shop page with product grid/list, filtering, search, and pagination./shop/:id– Single product details page./cart-page– Protected cart and checkout summary page./blog– Blog listing./blog/:id– Single blog post./about– About page./contact– Contact page./login– Login form (email/password, Google where configured)./sign-up– Sign-up form for new users.
Routes like /cart-page are wrapped with PrivateRoute, which checks AuthContext and redirects unauthenticated users to /login.
- AuthContext (
AuthProvider)- Exposes
user,loading,createUser,login,signUpWithGamil(Google sign-in), andlogout. - Subscribes to Firebase Auth state via
onAuthStateChanged.
- Exposes
- PrivateRoute
- Shows a loading state while auth is initializing.
- Renders protected children when
userexists. - Redirects to
/loginif not authenticated, preserving thefromlocation.
Update Firebase settings and enable providers (Email/Password, Google) in the Firebase console to match your .env config.
- Cart items are stored in
localStorageunder thecartkey. CartPage:- Reads initial cart state from
localStorage. - Allows increment/decrement of quantities.
- Supports removing items from the cart.
- Recalculates subtotal, shipping (e.g., 10% of subtotal), and total order cost.
- Reads initial cart state from
- A placeholder checkout form (
CheckOutPage) is rendered from the cart page and can be connected to real payment providers (Stripe, etc.) in the future.
Contributions, issues, and feature requests are welcome!
- Fork the repository.
- Create a feature branch:
git checkout -b feature/amazing-feature. - Commit your changes:
git commit -m "Add amazing feature". - Push to the branch:
git push origin feature/amazing-feature. - Open a Pull Request.
Please ensure:
- Code is formatted consistently.
- ESLint passes (
npm run lint). - New features are covered by basic tests or manual testing notes.
This project is currently unlicensed.
You may add a license of your choice (e.g., MIT) by creating a LICENSE file and updating this section.