Skip to content
Delightful data fetching for React.
TypeScript JavaScript CSS Other
Branch: master
Clone or download
Latest commit f32e9fe Aug 16, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci [internal] Make linters run (#27) Mar 29, 2019
.github [internal] Update PR template to use documentation for instructions Aug 6, 2019
.vscode [internal] Use installed typescript in vscode May 22, 2019
docs [pkg] Upgrade to @testing-library packages (#122) Aug 15, 2019
scripts [internal] Fix formatting to space typescript correctly Jun 9, 2019
src [internal] Update eslint rules Aug 15, 2019
website [pkg] Upgrade to @testing-library packages (#122) Aug 15, 2019
.dockerignore [docs] Setup docusarus for a real site Apr 21, 2019
.editorconfig Project dump Feb 23, 2019
.eslintignore Project dump Feb 23, 2019
.eslintrc [internal] Update eslint rules Aug 15, 2019
.gitignore Project dump Feb 23, 2019
.prettierrc [internal] Make linters run (#27) Mar 29, 2019
CHANGELOG.md [docs] Add changelog Feb 26, 2019
CONTRIBUTING.md Project dump Feb 23, 2019
Dockerfile [docs] Setup docusarus for a real site Apr 21, 2019
LICENSE Project dump Feb 23, 2019
README.md [docs] Add react native support as feature in readme list Jul 28, 2019
docker-compose.yml [docs] Setup docusarus for a real site Apr 21, 2019
jest.config.js [internal] Use absolute library imports (#92) Jul 5, 2019
package.json Release 2.1.1 Aug 15, 2019
rest_hooks_logo_and_text.svg [docs] Update logo (#71) Jun 3, 2019
rollup.config.js [pkg] Babel Jul 19, 2019
salus.yaml [internal] Disable salus yarnaudit until its fixed Jul 14, 2019
test.d.ts [breaking] RestProvider -> CacheProvider Jul 12, 2019
test.js [feature] Export utilities for testing and mocking (#55) Apr 29, 2019
tsconfig.json [pkg] Upgrade to @testing-library packages (#122) Aug 15, 2019
yarn.lock [internal] Update eslint rules Aug 15, 2019

README.md

🛌🎣 Rest hooks

CircleCI Coverage Status npm downloads gzip size npm version PRs Welcome

Making dynamic sites performant, scalable, simple to build with any API design.

Simple TypeScript definition

class ArticleResource extends Resource {
  readonly id: number | null = null;
  readonly title: string = '';
  readonly body: string = '';

  pk() { return this.id; }
  static urlRoot = '/articles/';
}

One line data hookup

const article = useResource(ArticleResource.detailShape(), { id });
return (
  <>
    <h2>{article.title}</h2>
    <p>{article.body}</p>
  </>
);

Mutation

const update = useFetcher(ArticleResource.updateShape());
return <ArticleForm onSubmit={data => update(data, { id })} />;

And subscriptions

const price = useResource(PriceResource.detailShape(), { symbol });
useSubscription(PriceResource.detailShape(), { symbol });
return price.value;

...all typed ...fast ...and consistent

For the small price of 7kb gziped.    🏁Get started now

Features

  • TS Strong Typescript types
  • 🛌 React Suspense support
  • 🎣 Simple declarative API
  • 💰 Normalized response caching
  • 💥 Tiny bundle footprint
  • 🛑 Automatic overfetching elimination
  • Optimistic updates
  • 🧘 Flexible to fit any API design (one size fits all)
  • 🌳 Tree-shakable (only use what you need)
  • 🔁 Subscriptions
  • ♻️ Optional redux integration
  • 📙 Storybook mocking
  • 📱 React Native support
  • 🚯 Pluggable garbage collection policy

Special thanks

Thanks to @0xcaff, @melissafzhang and @alexiswolfish for their valuable feedback.

You can’t perform that action at this time.