This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
This project was set up with NodeJS v20.11.0 LTS with yarn.
- Install packages
yarn
- Create a file
.env.development.local
in root folder with the following informationIf you would like to ignore mock service worker, set it toVITE_IGNORE_MSW=false
true
. - Create another file
.env.test.local
in root folder with same content as above - Run the development server
yarn dev
We shall be using these packages
- React Query for data fetching.
- Mock Service Worker to isolate develop on the frontend. You don't have to worry about backend code.
- React Router for routing.
- date-fns for any date related data processing.
- useHooks for useful hooks so you never have to write custom hooks.
Please look up the documentation on their websites for intended uses and best practices.
Currently, two official plugins are available:
- @vitejs/plugin-react uses Babel for Fast Refresh
- @vitejs/plugin-react-swc uses SWC for Fast Refresh
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