A custom React application template built with modern tooling and best practices.
Welcome! This template is designed to help you kickstart your next React project with ease and confidence. π
- React - JavaScript library for building user interfaces.
- TypeScript - Static typing for JavaScript, ensuring type safety and better developer experience.
- Yarn - Package manager (v4.0.2) for dependency management.
- ESLint - Code linting and style enforcement to maintain code quality.
- TypeDoc - Documentation generator for TypeScript projects.
- Vitest - A fast and lightweight testing framework for unit and integration tests.
- React Testing Library - Utilities for testing React components in a user-centric way.
- Playwright - End-to-end testing framework for browser automation.
- Native CSS - Uses modern native CSS features (custom properties, CSS Modules) without PostCSS.
- BEM Methodology - Block Element Modifier naming convention for consistent and maintainable CSS.
- CSS Modules - Scoped CSS for modular components.
- React Query - A powerful library for data fetching, caching, and synchronization.
- JSONPlaceholder - A free fake API used for testing and prototyping.
src/
βββ components/ # Reusable React components
βββ hooks/ # Custom React hooks
βββ services/ # API and service integrations
βββ types/ # TypeScript type definitions
βββ styles/ # Global styles
βββ tests/ # Test utilities and mocks
-
Install dependencies:
yarn install
-
Start the development server:
yarn dev
-
Run tests:
yarn test -
Generate documentation:
yarn docs
-
Lint code:
yarn lint
-
yarn dev
Starts the development server on port3000with hot module replacement (HMR) enabled. -
yarn preview
Serves the production build locally for previewing the app.
yarn build
Builds the application for production. This includes TypeScript compilation and bundling with Vite.
-
yarn test:unit
Runs all unit tests using Vitest with coverage enabled. -
yarn test:watch
Runs unit tests in watch mode for faster feedback during development. -
yarn test:e2e
Runs all end-to-end tests using Playwright. -
yarn test:e2e:ui
Opens the Playwright Test Runner UI for debugging and running tests interactively. -
yarn test:e2e:codegen
Launches Playwright's codegen tool to record user interactions and generate test scripts:yarn test:e2e:codegen http://localhost:3000
-
yarn lint
Runs ESLint to check for code quality and style issues. -
yarn lint:fix
Runs ESLint and automatically fixes fixable issues.
yarn typecheck
Runs TypeScript's type checker to ensure type correctness without emitting files.
-
yarn docs
Generates project documentation using TypeDoc and outputs it to thedocsdirectory. -
yarn docs:watch
Watches for changes and regenerates documentation in real-time. -
yarn docs:open
Opens the generated documentation (docs/index.html) in the default browser.
You can easily deploy your app to GitHub Pages for free! π
-
Build your app for production:
yarn build
-
Deploy to GitHub Pages:
yarn deploy
This will publish the contents of your
distfolder to thegh-pagesbranch and make your app available athttps://<your-username>.github.io/<your-repo>/.
Tip:
Make sure yourvite.config.tsis configured with the correctbasepath for GitHub Pages, e.g.:// vite.config.ts export default defineConfig({ base: '/<your-repo>/', // ...other config });
A GitHub Actions workflow is configured to run Playwright end-to-end tests on every push or pull request to the main or master branches. The workflow installs dependencies, sets up Playwright, and runs the tests.
Another GitHub Actions workflow is configured to run unit tests using Vitest. It ensures that all unit tests pass on every push or pull request to the main or master branches.
- Hot Module Replacement - Instant updates during development.
- Type Checking - Real-time TypeScript type checking.
- Documentation Generation - Automatic API documentation with TypeDoc.
- Testing Setup - Pre-configured with Vitest, React Testing Library, and Playwright.
- CSS Modules - Scoped styling with BEM methodology.
- API Mocking - Easy API mocking for testing.
The project uses React Router v7 for client-side routing. Key features include:
- Nested Routes - Organize routes hierarchically.
- Dynamic Parameters - Access route parameters using
useParams. - Route Guards - Protect routes with authentication.
- Lazy Loading - Load routes on demand for better performance.
- Memory Router - Test routes in isolation.
/ # Home page with post list
/posts/:id # Individual post detail page
The project uses Vitest, React Testing Library, and Playwright for testing.
Run unit tests with:
yarn test:unitRun specific tests in watch mode:
yarn test:unit --watch src/components/PostDetailRun E2E tests with:
yarn test:e2eUse the Playwright Test Runner UI:
yarn test:e2e:uiGenerate E2E tests using Playwright Codegen:
yarn test:e2e:codegen http://localhost:3000- BEM Methodology - Consistent and maintainable CSS class naming.
- CSS Modules - Scoped styles for components.
- Native CSS - Modern native CSS features and CSS Modules for component styles.
- Responsive Design - Mobile-first approach with the following breakpoints:
- π± Mobile:
< 768px - π» Tablet:
768px - 1024px - π₯οΈ Desktop:
> 1024px
- π± Mobile:
The project uses JSONPlaceholder as a mock API for demonstration purposes. API calls are handled using the native fetch API and managed with React Query for efficient data fetching and caching.
This project is licensed under the MIT License - see the LICENSE file for details.