Skip to content
Delightful data fetching for React.
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci [internal] Make linters run (#27) Mar 29, 2019
.github/ISSUE_TEMPLATE typo in bug report template (#26) Mar 27, 2019
.vscode [internal] Standardize formatting Apr 29, 2019
docs [docs] Add comment to sequential resource guide May 7, 2019
scripts [internal] Move some root level files to dirs (#62) May 4, 2019
src [internal] Move some root level files to dirs (#62) May 4, 2019
website [docs] Add testing utility docs and guides (#58) May 2, 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] Make linters run (#27) Mar 29, 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
docker-compose.yml [docs] Setup docusarus for a real site Apr 21, 2019
index.js [feature] Export utilities for testing and mocking (#55) Apr 29, 2019
jest.config.js [internal] Move some root level files to dirs (#62) May 4, 2019
package.json [internal] Auto publish changelog during release-it May 6, 2019
rollup.config.js [feature] Export utilities for testing and mocking (#55) Apr 29, 2019
salus.yaml [internal] Add salus to check security Mar 12, 2019
test.d.ts [docs] Add testing utility docs and guides (#58) May 2, 2019
test.js [feature] Export utilities for testing and mocking (#55) Apr 29, 2019
tsconfig.json Project dump Feb 23, 2019
yarn.lock [enhance] Make unpkg (production) build set env to production for dev… Apr 24, 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.singleRequest(), { id });
return (
  <>
    <h2>{article.title}</h2>
    <p>{article.body}</p>
  </>
);

Mutation

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

And subscriptions

const price = useResource(PriceResource.singleRequest(), { symbol });
useSubscription(PriceResource.singleRequest(), { 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
  • 🚯 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.