Skip to content
Simple and powerful API client for react πŸ‘ Use hooks or FACCs to fetch data in easy way. No dependencies! Just react under the hood.
Branch: master
Clone or download
marcin-piela Merge pull request #33 from marcin-piela/dependabot/npm_and_yarn/hand…
…lebars-4.1.2

Bump handlebars from 4.1.0 to 4.1.2
Latest commit 3ca7ca9 Jun 5, 2019

README.md

Simple and powerful fetching library for React. Use hooks to fetch data!

Watch on GitHubStar on GitHubTweet


Build Status version downloads MIT License PRs Welcome Code of Conduct Code of Conduct codecov

βœ… Zero dependencies (react, react-dom as peer deps)

βœ… SSR support

βœ… Use hooks or FACC's (Function as Child Components) - depending on your needs

βœ… Uses Fetch API

βœ… Request and response interceptors allows to easily customize connection with API

βœ… React Suspense support (experimental *)

βœ… TypeScript support

βœ… Error boundaries to catch bad API responses

βœ… Less than 3k minizipped

βœ… Simple cache provider - easily to extend


react-fetching-library

Use hooks or FACC's (Function as Child Component) to fetch data in an easy way. No dependencies! Just React under the hood.

Request and response interceptors allows you to easily customize connection with API (add authorization, refresh token, cache, etc). It uses Fetch API so it can be use in SSR apps (ie. with isomorphic-fetch)

Library allows you to use it with connection of React Suspense (read more about React Suspense) to easily maintain loading state in application.

Documentation

Full documentation is available at https://marcin-piela.github.io/react-fetching-library

Short example of use

import { useQuery } from 'react-fetching-library';

const fetchUsersList = {
  method: 'GET',
  endpoint: '/users',
};

export const UsersListContainer = () => {
  const { loading, payload, error, query } = useQuery(fetchUsersList);

  return <UsersList loading={loading} error={error} users={payload} onReload={query} />;
};

Edit Basic Example

Typescript support

Inspirations

Contributing

Fell free to open PRs and issues to make this library better !

When making a PR, make sure all tests pass. If you add a new feature, please consider updating the documentation or codesandbox examples. Thank you!

Using Suspense to fetch data

For now React Suspense is not production ready to use it for fetch data as described here, so API of our component/hook may change in the future.

License

react-fetching-library is licensed under the MIT license.

You can’t perform that action at this time.