use-fetch-cache
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

Build Status

useFetchCache

This is just a wrapper around the useSWR hook that adds the initial data to the cache and fetches the data when there is no initial data available.

Why

When you use Server Side Rendering to render you page and provide initial data this data is not stored in the cache. That means that for the cache to work you need an extra client-side fetch, which will only add unnecessary load to the backend.

How to use

The signature is exactly the same as the current signature of useSWR.

Notes

If you don't provide initial data this hook will fetch the data for you on mount.

Readme

Keywords

Package Sidebar

Install

npm i use-fetch-cache

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

4.81 kB

Total Files

5

Last publish

Collaborators

  • enrise