React Query, Zustand, TypeScript & Vite Boilerplate

This is a template repository to set up a project using React, React Query, Zustand, TypeScript, and Vite, aiming to provide a scalable structure and essential configurations to kick-start your next application.

Stack

ToolPurpose
ReactA JavaScript library for building user interfaces
React QueryData synchronization library for React
ZustandMinimalist state management
TypeScriptStatic typing for JavaScript
ViteBuild tool and development server

Features

:white_check_mark: Faster build with Vite

:white_check_mark: State management using Zustand

:white_check_mark: Data fetching using React Query and Axios

:white_check_mark: TypeScript for static typing

:white_check_mark: Pre-configured with ESLint and Prettier for code linting and formatting

:white_check_mark: Includes example components to get started quickly

Required Versions

ToolVersion
NodeJS>=16
TypeScript>=4.9.4

Getting Started

Clone the repository

git clone https://github.com/vintagegnome/react-query-zustand-ts-vite-boilerplate.git
cd react-query-zustand-ts-vite-boilerplate

Installing Dependencies

npm install

Running Locally

To run the project locally, simply execute:

npm run dev

Scripts

CommandDescription
startRun build:css then watch TailwindCSS and Vite concurrently
watch:cssWatch for changes in index.css and output to styles.css using TailwindCSS
build:cssBuild CSS using TailwindCSS from index.css to styles.css
buildRun TypeScript compiler, build CSS and then Vite build
previewRun Vite preview
lintLint TypeScript files using ESLint
lint:fixFix linting issues in TypeScript files using ESLint
formatFormat .ts, .tsx, and .json files using Prettier
testRun Jest tests
releaseRun standard-version for versioning
commitUse git-cz for commits
prepareSet up Husky for git hooks in a production environment

Project Structure

Here's a basic overview of the significant folders in the boilerplate:

├── public
└── src
  ├── components
  ├── hooks
  ├── lib
  ├── pages
  ├── routes
  ├── services
  ├── store
  └── types
FolderDescription
src/Contains the main source code for the application.
componentsReusable React components, each handling a specific piece of the UI.
hooksCustom React hooks that encapsulate logic and behaviors which can be reused across different components.
libMiscellaneous utility functions, helpers, and other standalone pieces of logic.
pagesComponents representing full pages in the application, typically corresponding to routes.
routesConfiguration and components related to routing in the application.
servicesFunctions or classes that handle tasks like API calls, data processing, or other "service"-like tasks.
storeZustand st ores for state management, holding
public/Contains static assets like images, fonts, and the entry HTML file. Assets in this directory are served directly and are not processed by bundlers like Vite.

Features

Tool/LibraryDescription
React QueryHelps in fetching, caching, and updating asynchronous data.
ZustandFor simple and scalable state management.
TypeScriptFor type-safe code and scalability.
ViteFor faster builds and a smoother developer experience.

Contribution

If you'd like to contribute to this boilerplate, feel free to fork and send a PR. All contributions are welcome!

License

MIT