React project folder structure

# React Tips# Snippets

In this article, I will share some ideas on how to structure your react project.

├── components
├── context
├── data
├── hooks
├── pages
├── services
├── utils
├── App.jsx
└── main.js


All of our components will be in this folder. We can have subfolders for each component type. For example, we can have a folder for all of our buttons, another folder for all of our inputs, and so on. These are mostly components that are shared between pages and don't implement any business logic.


This folder contains all of our pages. Each page is a component that is exported as default. Components in this folder represent different routes in our application.


In the application we gonna always have a react context or Redux context to use. For example an entire shopping cart can live in a context. We put all of our contexts in this folder.


This is a folder to store all of our data. Any JSON data that we need to use in our application should be stored here.


This is for all of our custom hooks, such as useLocalStorage, useFetch, and so on.


This is for all of our services. For example, we can have a service to fetch data from an API.


A collection of small functions mosly pure functions. For example, a function to convert a string to a slug. Another example would be a function to convert a number to a currency string.