Welcome to the folder structure for your NextJS React Query application! Feel free to customize and adapt this structure to fit the unique needs of your project. Remember, there is no one-size-fits-all solution when it comes to organizing your project folders.
In /src folder you can find example for simple News website project.
- common
types.ts- generic types based on you API. Example:PaginatedResponse<T>.
- [domain-name] example - news
types.ts- types only for this domainfetchers.ts- pure JS fetchers for this[domain-name]entitiesqueries.ts- react query hooks for this[domain-name]entities
Define your application routes. Keep components free of logic and focus on loading data and rendering components from /components/[page-name]/[PageName].tsx.
- common - Includes shared components like Header and Footer.
- header (example of common components)
Header.tsx
- header (example of common components)
- [page-name]
- components - Specific components for
[PageName].tsx.- component-a
- components - Specific components for
ComponentA.tsx. ComponentA.tsx- Utilizes components from./componentsorsrc/components/common.constants.tstypes.tshelpers.ts
- components - Specific components for
- component-a
[PageName].tsx- Utilizes components from./componentsorsrc/components/common.constants.ts- component specific constantstypes.ts- component specific typeshelpers.ts- component specific helpers
- components - Specific components for
Centralize app constants, such as variables.ts and pages.ts.
Project-specific helpers go here.
Define custom hooks, e.g., useClickOutside or useDebounce, for across-the-board use.
Design providers for the application within this folder.
global.css- Includes configurations for Tailwind CSS.
Reusable utilities like date helpers or object utilities belong in this folder. Keep utils free of business logic.
Feel free to explore and adapt this structure to align with the needs of your NextJS React Query application. Enjoy coding and happy building! 🚀🌟