Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 1.15 KB

File metadata and controls

42 lines (30 loc) · 1.15 KB

client-suspense GitHub license BundlePhobia

ClientSuspense component (client-only Suspense)

A component that suspends only on the client side.

Usage

For example, if you use nextjs with streaming related APIs, Suspense will be suspended on the server side. To avoid this you can use ClientSuspense like this:

import { ClientSuspense } from 'client-suspense';

export const App = () => {
  return (
    <div>
      <ClientSuspense
        fallback={(
          <Spinner />
        )}
      >
        <OtherComponent />
      </ClientSuspense>
    </div>
  );
};

And that's all it takes!

Installation

Recommend to use yarn for dependency management:

yarn add client-suspense

License

client-suspense is MIT licensed.