Skip to content

Orva-Studio/lite-query

Repository files navigation

Lite Query

Basic Usage

import { useQuery } from './utils/lite-query';

const { data, error, isLoading } = useQuery({
	queryKey: 'posts',
	queryFn: () => fetch('https://jsonplaceholder.typicode.com/posts').then(res => res.json())
});

if (isLoading) return 'Loading...';
if (error) return `Error: ${error.message}`;

How to Install

Simply copy this file and put it anywhere in your project.

Or if you'd like to install it as a package, you can use this command:

npx jsr add @orva/lite-query

Features

Lite Query address all the data fetching issues raised in the React Documentation caused by the useEffect hook such as:

  • Data Caching: Simple caching system preventing multiple requests for the same data.
  • Prefetching: Fetch data before it's needed, or even before React renders the component.
  • SWR: Stale-While-Revalidate supported meaning you can show stale data while fetching new data in the background.
  • And much more...: Learn more about all the features in the Lite Query Docs.

About

The lightweight, single-file data loading library for React.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published