- Introduction
- Technologies Used
- Project Structure
- Getting Started
- Key Features
- Usage
- Contributing
- License
This project demonstrates the integration of HeyApi, Tanstack Query, and Tanstack Router in a modern React application built with TypeScript and Vite. The goal is to showcase a real-world example of how to manage API requests, client-side caching, and routing in a performant and scalable React application.
By combining these powerful tools, this project helps developers build efficient data-fetching strategies, optimize user experiences, and create maintainable applications with minimal configuration overhead.
- React - A JavaScript library for building user interfaces
- TypeScript - A typed superset of JavaScript that compiles to plain JavaScript
- Vite - A fast development build tool
- HeyApi - A powerful API service for building and managing APIs easily
- Tanstack Query - A powerful asynchronous state management library for handling API requests and caching
- Tanstack Router - A lightweight routing solution optimized for React
- Prerequisites Make sure you have the following installed on your system:
Node.js (v14 or higher) npm or yarn
Make sure you have the following installed on your system:
- Node.js (v14 or higher)
- npm or yarn
Clone the repository:
git clone https://github.com/your-username/your-repo-name.git
cd your-repo-name
- API Management with HeyApi: Integration with HeyApi for seamless API request handling.
- Data Fetching Caching with Tanstack Query: Efficiently fetch and cache data to improve performance.
- Routing with Tanstack Router: Lightweight and modern routing for React applications.
- TypeScript Support: Ensures type safety and scalability with TypeScript throughout the app.
- Vite for Fast Builds: Instant server start and fast hot module replacement (HMR) during development.
- To define API endpoints and manage data fetching, navigate to the src/api and src/services directories.
- To add routes, use the src/router directory where Tanstack Router is configured.
- Reusable components can be added to the src/components folder to keep your UI modular.
Here's a brief example of how to set up Tanstack Query with HeyApi:
import { useQuery } from '@tanstack/react-query';
import { fetchData } from './api';
const MyComponent = () => {
const { data, isLoading, error } = useQuery(['key'], fetchData);
if (isLoading) return <p>Loading...</p>;
if (error) return <p>Error loading data</p>;
return <div>{data?.message}</div>;
};
- Contributions are welcome! If you’d like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcomed.
- Fork the project
- Create a feature branch (git checkout -b feature/AmazingFeature)
- Commit your changes (git commit -m 'Add some AmazingFeature')
- Push to the branch (git push origin feature/AmazingFeature)
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.