dragenet / ts-vite-react-template

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Modern Tooling React Templates

This repository contains two React templates for starting a project with modern tooling, including Vite, SWC, Vitest, Redux Toolkit, etc. The templates are organized into separate folders and are available on the branch. These templates can be used as a solid starting point for building a React application with the latest tooling and best practices.

πŸ“Templates

1. Base Template

This template contains the following:

  • Vite
  • React
  • SWC
  • Styled Components
  • svgr
  • Vitest
  • Testing Library
  • Eslint
  • Prettier
  • lint-staged

2. With Redux Toolkit Template

This template contains the following:

  • Vite
  • React
  • SWC
  • Styled Components
  • svgr
  • Vitest
  • Testing Library
  • Eslint
  • Prettier
  • lint-staged
  • Redux Toolkit

πŸ”§ Installation

To use the templates, follow the steps below:

  1. Install degit:

    pnpm add -g degit
    
  2. Clone the repository:

    • Base Template:
      degit  https://github.com/dragenet/ts-vite-react-template.git/base <target-dir>
      
    • With Redux Toolkit:
      degit  https://github.com/dragenet/ts-vite-react-template.git/with-redux-toolkit <target-dir>
      
  3. Change directory to the desired template:

    cd <target-dir>
    
  4. Initialize git:

    git init
    
  5. Install dependencies:

    pnpm install
    
  6. Start the development server:

    pnpm dev
    

πŸ“ Template Structure

Each template has the following file and folder structure (excluding store directory):

β”œβ”€β”€ index.html
β”œβ”€β”€ package.json
β”œβ”€β”€ pnpm-lock.yaml
β”œβ”€β”€ public
β”‚   └── vite.svg
β”œβ”€β”€ src
β”‚   β”œβ”€β”€ main.tsx
β”‚   β”œβ”€β”€ App.tsx
β”‚   β”œβ”€β”€ assets
β”‚   β”œβ”€β”€ components
β”‚   β”‚   β”œβ”€β”€ molecules
β”‚   β”‚   β”‚   β”œβ”€β”€ Helmet
β”‚   β”‚   β”‚   └── RootProvider
β”‚   β”‚   └── templates
β”‚   β”‚       └── HomePageTemplate
β”‚   β”œβ”€β”€ pages
β”‚   β”‚   β”œβ”€β”€ Home.tsx
β”‚   β”œβ”€β”€ router
β”‚   β”œβ”€β”€ store (*only for with-redux-toolkit template)
β”‚   β”‚   β”œβ”€β”€ apis
β”‚   β”‚   β”œβ”€β”€ hooks
β”‚   β”‚   β”‚   β”œβ”€β”€ useAppDispatch.ts
β”‚   β”‚   β”‚   └── useAppSelector.ts
β”‚   β”‚   β”œβ”€β”€ rootStore.ts
β”‚   β”‚   └── slices
β”‚   β”œβ”€β”€ theme
β”‚   β”œβ”€β”€ types
β”‚   β”‚   └── env.d.ts
β”‚   └── utils
β”‚       └── test
β”‚           β”œβ”€β”€ renderTest.tsx
β”‚           └── withTestRouter.tsx
β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ tsconfig.node.json
β”œβ”€β”€ vite.config.ts
└── vitest.setup.ts

πŸ“ Contribution

If you find any bug or have any suggestion, feel free to open an issue or submit a pull request.

πŸ” License

This project is licensed under the MIT License - see the LICENSE.md file for details.

About

License:MIT License


Languages

Language:TypeScript 78.9%Language:JavaScript 16.8%Language:HTML 3.6%Language:Shell 0.7%