This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. This is a typescript project using Tailwind CSS. A simple project structure is setup with dummy data and commonly used libraries such as Axios and React Router are installed and configured.
- clone this repo
git clone git@github.com:mrlinnth/react-vite-starter.git
- enter the directory
- copy
.env.example
to.env.local
- run
yarn
- run
yarn dev
- React Router
- Check
Router.tsx
,Layout.tsx
,Guard.tsx
,Error.tsx
for basic usage
- Recoil
- Check
Home
andPlayground
components inpages
directory for basic usage - Check
utils/atoms.ts
for Recoil atoms
- axios
- TanStack React Query
- React Query and Axios with Typescript
- JSONPlaceholder
- Check
utils/https.ts
for axios instance - Check
services/PostService.ts
for API calls - Check
useAllPosts
hook andPlayground
component for basic React Query usage
- ESLint
- Prettier
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
- Configure the top-level
parserOptions
property like this:
export default {
// other rules...
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname
}
};
- Replace
plugin:@typescript-eslint/recommended
toplugin:@typescript-eslint/recommended-type-checked
orplugin:@typescript-eslint/strict-type-checked
- Optionally add
plugin:@typescript-eslint/stylistic-type-checked
- Install eslint-plugin-react and add
plugin:react/recommended
&plugin:react/jsx-runtime
to theextends
list