Skip to content

A minimal, clean, and scalable React starter template focused on best practices and modern design patterns. This boilerplate provides a solid foundation for building React applications with TypeScript, emphasizing maintainability, reusability, and performance.

Notifications You must be signed in to change notification settings

connect-bilal/react-design-patterns-starter

Repository files navigation

React Design Patterns Starter

A minimal and scalable React starter template focused on best practices and modern design patterns. This boilerplate is designed to help you build maintainable, reusable, and performant React applications with TypeScript.


Features

  • TypeScript ready with strict typings
  • Atomic design principles for component organization
  • React Hooks and Context API support
  • Modular and scalable folder structure
  • Reusable UI components: Button, Text, Container, etc.
  • Utility-first styling with Tailwind CSS
  • Storybook integration for isolated UI development
  • Code quality tools: ESLint and Prettier
  • Performance optimizations using React.memo and forwardRef
  • Easily extendable for routing, state management, and API integration

Tailwind CSS

  • Fully integrated with Tailwind CSS for utility-first styling
  • Supports custom theming via CSS variables for colors, fonts, and spacing
  • Enables fast, consistent styling while maintaining a scalable, maintainable design system

Prerequisites

  • Node.js (>=14.x)
  • npm or yarn package manager

Installation

git clone https://github.com/connect-bilal/react-design-patterns-starter.git
cd react-design-patterns-starter
npm install
# or
yarn install

Customize to Fit Your Needs

  • πŸ”§ Update global styles and themes in src/styles/
  • 🎨 Modify or extend atomic components in src/common/
  • 🧱 Create new features using the pre-defined folder structure and design patterns
  • πŸ“– Check the Storybook documentation to explore available components and see usage examples for each one

πŸ“¦ Included Dependencies

Core Dependencies

Package Description
react The core library for building UI components.
react-dom React DOM bindings for rendering to the browser.
react-router-dom Declarative routing for React applications.
react-helmet Manage document head for SEO optimization.
clsx Utility for conditionally joining class names.
react-icons Popular icons (FontAwesome, Material, etc.) as React components.

Dev Dependencies

πŸ›  Build & Tooling

Package Description
vite Fast, modern build tool with native ESM support.
@vitejs/plugin-react Vite plugin for React.
vite-tsconfig-paths Supports TypeScript path aliases in Vite.
typescript TypeScript language support.

βœ… Linting & Formatting

Package Description
prettier Opinionated code formatter.
eslint-config-prettier Disables ESLint rules that conflict with Prettier.
eslint-plugin-import Linting support for ES6+ import/export syntax.
eslint-plugin-jsx-a11y Accessibility linting for JSX elements.
eslint-plugin-react Linting for React components and patterns.
eslint-plugin-react-hooks Ensures correct usage of React Hooks.
eslint-plugin-react-refresh ESLint rules for React Fast Refresh.
eslint-plugin-storybook Storybook-specific linting rules.

πŸ§ͺ Testing

Package Description
vitest Vite-native unit testing framework.
@vitest/browser Browser-based testing support.
@vitest/coverage-v8 Coverage reports using V8 instrumentation.
playwright End-to-end testing with modern browser support.

πŸ“š Storybook (Component Documentation)

Package Description
@storybook/react Main Storybook package for React.
@storybook/react-vite Vite integration with Storybook.
@storybook/addon-essentials Core set of useful addons.
@storybook/experimental-addon-test Integrates tests with stories.
@storybook/blocks Visual layout and component blocks.
@storybook/test Addon to run automated tests on stories.
@chromatic-com/storybook Visual testing and deployment with Chromatic.

🧹 Git Hooks & Commit Hygiene

Package Description
husky Manage Git hooks easily (e.g., pre-commit hooks).
lint-staged Run linters only on staged files.

🧰 Key Features

  • βœ… React 19 with TypeScript
  • ⚑ Vite for blazing-fast development and builds
  • πŸ›  ESLint + Prettier + Husky + Lint-Staged
  • πŸ§ͺ Vitest + Playwright for testing
  • 🌐 SEO-ready with react-helmet
  • πŸ“– Storybook for component development
  • πŸ“¦ Organized folder structure based on best practices

Project Structure

src/
β”œβ”€β”€ assets/              # Static assets like images, fonts, icons, and svgs
β”œβ”€β”€ components/          # Reusable UI components following Atomic Design principles
β”‚   β”œβ”€β”€ common/          # Base-level atomic components (Button, Text, Container)
β”‚   β”‚   β”œβ”€β”€ Alert/               # Alert component
β”‚   β”‚   β”œβ”€β”€ Button/               # Button component
|   β”‚   β”‚   β”œβ”€β”€ Button.tsx            # Main Button component
β”‚   β”‚   β”‚   β”œβ”€β”€ Button.types.ts       # Props types / interfaces
β”‚   β”‚   β”‚   β”œβ”€β”€ Button.styles.ts      # Tailwind style definitions
β”‚   β”‚   β”‚   β”œβ”€β”€ Button.stories.ts     # Storybook story
β”‚   β”‚   β”‚   β”œβ”€β”€ index.ts              # Re-export for cleaner imports
β”‚   β”‚   β”œβ”€β”€ Container/            # Container/layout component
β”‚   β”‚   β”œβ”€β”€ Divider/              # Divider component
β”‚   β”‚   β”œβ”€β”€ Input/                # Reusable input field component
β”‚   β”‚   β”œβ”€β”€ Label/                # Label component
β”‚   β”‚   β”œβ”€β”€ Link/                 # Styled wrapper for internal and external links
β”‚   β”‚   └── Text/                 # Text/typography component
β”‚   β”‚   β”œβ”€β”€ Icon/                 # Icon component with SVG support
β”‚   β”‚   └── Link/                 # Link component with external/internal support
β”‚   β”‚   └── SEO/                  # SEO component to manage meta tags (Open Graph, Twitter, etc.)
β”‚   β”‚   └── Toggle/               # Toggle component for switch or checkbox functionality
β”‚   β”‚   └── ThemeSwitcher/        # Wrapper component using Toggle & ThemeContext
β”‚   β”‚   └── TruncateText/         # Truncates long text with "Less" and "More" toggle support
β”‚   └── hoc/             # Higher-Order Components
β”‚   β””β”€β”€β”œβ”€β”€ index.ts         # Central re-export
β”‚   └── layouts/            # Reusable layout wrappers and page structures (e.g. Page, AppShell)
β”‚       β”œβ”€β”€ index.ts        # Central re-export of layout components
β”‚       └── Page/           # Page layout component for consistent page structure
β”œβ”€β”€ constants/           # Application-wide constants, enums, and configuration values
β”œβ”€β”€ context/                # Global app state with React context
β”‚   β”œβ”€β”€ ThemeContext.tsx    # Theme context (light/dark toggle)
β”‚   |── index.ts            # Contexts export
β”œβ”€β”€ hooks/               # Custom React hooks for shared logic across app
β”‚   β”œβ”€β”€ useTheme.ts         # Manages light/dark theme state and toggle logic
β”‚   β”œβ”€β”€ useTitle.ts         # Sets and updates the document title dynamically
β”‚   β”œβ”€β”€ useWindowWidth.ts   # Tracks and returns current window width (responsive utility)
β”‚   └── index.ts            # Central export file for all custom hooks
β”œβ”€β”€ i18n/                # Localization files and i18n config (e.g., en.json, fr.json)
β”œβ”€β”€ lib/                 # Library modules & integrations (API clients, services)
β”‚   |── index.ts         # Library export
β”œβ”€β”€ pages/               # Route-level components (pages/screens)
β”œβ”€β”€ services/            # API calls, business logic
β”œβ”€β”€ store/               # State management (Redux, Zustand, or Context)
β”œβ”€β”€ styles/              # Global styles, theme files, and CSS Modules
β”‚   β”œβ”€β”€ global.css       # Base styles, CSS resets, and global styling
β”‚   β”œβ”€β”€ theme.css        # Theme-related styles (e.g., light and dark mode overrides)
β”‚   β”œβ”€β”€ utilities.css    # Custom Tailwind utility classes and overrides for extended styling
β”‚   └── token.ts         # Design tokens and reusable style constants (colors, spacing, typography, state classes)
β”œβ”€β”€ types/               # TypeScript type definitions and interfaces
β”œβ”€β”€ utils/               # Utility functions and helpers (formatting, API calls, etc.)
β”‚   β”œβ”€β”€ capitalize.ts       # Capitalize the first letter of a string
β”‚   β”œβ”€β”€ clamp.ts            # Clamp a number between a min and max
β”‚   β”œβ”€β”€ isClient.ts         # Check if code is running in a browser environment
β”‚   β”œβ”€β”€ isValidLiteral.ts   # Validate if a value matches allowed literals (e.g., enums)
β”‚   β”œβ”€β”€ mergeRefs.ts        # Combine multiple refs into one
β”‚   β”œβ”€β”€ truncate.ts         # Shorten text with ellipsis based on limit
β”‚   β”œβ”€β”€ uuid.ts             # Generate a unique identifier
β”‚   └── index.ts            # Central export for all utility functions
β”œβ”€β”€ App.tsx              # Root application component
└── index.tsx            # Application entry point, rendering <App />

πŸ“˜ Storybook Preview

Explore the live Storybook documentation to see the components in action, following the React Design Patterns used in this project:

πŸ”— View Storybook

Frequently Asked Questions (FAQs)

Q: Can I remove components I don’t need?
A: To remove unused components, simply delete their folder inside src/components/common/ and remove their export from
src/components/common/index.ts.

Q: Can I use this starter for commercial projects?
A: Absolutely! This starter is free to use and modify for personal or commercial projects. Just please don’t redistribute it as your own starter template.

License – Bilal Ahmad Khan

This React starter template is provided free of charge for building personal or commercial products and applications.

βœ” You MAY:

  • Use this project to build your own app or product
  • Modify the code as needed
  • Share your own built products

❌ You MAY NOT:

  • Resell, redistribute, or republish this project as a starter template, boilerplate, or development kit
  • Claim ownership of the original project structure for educational or starter purposes

Contact me for approval if you wish to use it as a base for another starter/template.


🚧 Work in Progress… Stay tuned!

About

A minimal, clean, and scalable React starter template focused on best practices and modern design patterns. This boilerplate provides a solid foundation for building React applications with TypeScript, emphasizing maintainability, reusability, and performance.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published