Skip to content

jrcribb/suspense

 
 

Repository files navigation

suspense

APIs to simplify data loading and caching. Primarily intended for use with React Suspense.

⚠️ Considerations

  1. Suspense is an experimental, pre-release feature; these APIs will change along with React.
  2. This package depends on react@experimental and react-dom@experimental versions.

Example

import { createCache } from "suspense";

const userProfileCache = createCache({
  load: async ([userId]) => {
    const response = await fetch(`/api/user?id=${userId}`);
    return await response.json();
  },
});

function UserProfile({ userId }) {
  const userProfile = userProfileCache.read(userId);

  // ...
}

More examples at suspense.vercel.app.

If you like this project, buy me a coffee.

About

Utilities for working with React Suspense

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 94.3%
  • CSS 5.2%
  • Other 0.5%