suspense
TypeScript icon, indicating that this package has built-in type declarations

0.0.53 • Public • Published

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.

If you like this project, 🎉 become a sponsor or ☕ buy me a coffee

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.

/suspense/

    Package Sidebar

    Install

    npm i suspense

    Weekly Downloads

    1,837

    Version

    0.0.53

    License

    MIT

    Unpacked Size

    519 kB

    Total Files

    97

    Last publish

    Collaborators

    • brianvaughn