This project is a demonstration of how to use React Query library to perform the following frontend API requests:
- Basic query
- Paginated query
- Infinite query
- Create, Update and Delete requests
This demo project is setup with:
- Vite: A very fast build tool
- WindiCSS: A very fast Tailwind CSS compiler
- React Hook Form: Form builder and validation library
- React Modal: An accessible modal component
- Axios: Promised based HTTP client for browsers
- JSON Server: Full fake REST API server
I've written a breakdown article for this project which is available on Sitepoint.
Clone the project
git clone git@github.com:sitepoint-editors/react-query-demo.git
Go to the project directory
cd react-query-demo
Install dependencies
npm install
Setup database file
cp api/sample.db.json api/db.json
Start the json-server
npm run json-server
Launch another terminal and start the Vite server
npm run dev
Head over to your browser and open the URL http://localhost:3000 to access the application.
Copyright (c) 2021 SitePoint
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.