(Currently in development and not production-ready)

react-sus
 

npm i react-sus

Minimal Suspense-based data-fetching

Example

import { Suspense } from "react";
import { sus } from "react-sus";

interface User {
  username: string;
}

const SomeComponent = ({ userID }: { userID: string }) => {
  const data = sus<User>(`https://api.example.com/user/${userID}`);
  return <div>{data.username}</div>;
};

const App = () => (
  <Suspense fallback={<div>Loading...</div>}>
    <SomeComponent userID={"example"} />
  </Suspense>
);

Inspirations

This project seeks to combine the simplicity of swr with react-query’s feature set and suspend-react’s suspense support.

Related Projects

  • snowstorm – The lightning-fast and minimalist React Tool

GitHub

View Github