Skip to content

Manage asynchronous operations, timing, error handling, detecting intersection of elements, and caching easily and declaratively (One of TanStack Query community resources)

License

Notifications You must be signed in to change notification settings

love1ace/suspensive

Repository files navigation


MIT License PRs Welcome Commitizen friendly

GitHub stars GitHub stars



npm version npm bundle size npm

All declarative components to use suspense on both CSR, SSR.

Features

  • Suspense (containing CSROnly mode)
  • ErrorBoundary
  • ErrorBoundaryGroup, useErrorBoundaryGroup
  • AsyncBoundary (CSROnly mode)
  • Delay (Experimental)
  • SuspensiveProvider, SuspensiveConfigs (Experimental)
  • HOC(Higher Order Component)s for all components

Installation

npm install @suspensive/react
yarn add @suspensive/react
pnpm add @suspensive/react

Usage

import { Suspense, ErrorBoundary, ErrorBoundaryGroup } from '@suspensive/react'

const Example = (
  <ErrorBoundaryGroup>
    <ErrorBoundaryGroup.Reset trigger={(group) => <Button onClick={group.reset}>Reset All</Button>} />
    <ErrorBoundary fallback={(caught) => <Button onClick={caught.reset}>Reset {caught.error}</Button>}>
      <Suspense fallback={<Spinner />}>
        <SuspendedComponent />
      </Suspense>
    </ErrorBoundary>
    <ErrorBoundary fallback={(caught) => <Button onClick={caught.reset}>Reset {caught.error}</Button>}>
      <Suspense fallback={<Spinner />}>
        <SuspendedComponent />
      </Suspense>
    </ErrorBoundary>
  </ErrorBoundaryGroup>
)


npm version npm bundle size npm

Declarative apis to use @tanstack/react-query with suspense easily.

Features

  • QueryErrorBoundary, QueryAsyncBoundary
  • useSuspenseQuery
  • useSuspenseInfiniteQuery

Installation

npm install @suspensive/react @suspensive/react-query
yarn add @suspensive/react @suspensive/react-query
pnpm add @suspensive/react @suspensive/react-query

Usage

import { Suspense } from '@suspensive/react'
import { QueryErrorBoundary, useSuspenseQuery } from '@suspensive/react-query'

const Example = () => (
  <QueryErrorBoundary fallback={(caught) => <Button onClick={caught.reset}>Reset {caught.error}</Button>}>
    <Suspense fallback={<Spinner />}>
      <SuspendedComponent />
    </Suspense>
  </QueryErrorBoundary>
)

const SuspendedComponent = () => {
  const query = useSuspenseQuery(key, queryFn, options)

  return <>{query.data}</>
}


Docs deployment

We provide Official Docs

See OFFICIAL DOCS



Visualization deployment

Concepts Visualization ready. You can see core concepts of Suspensive visually

See VISUALIZATION.



License

MIT © Suspensive. See LICENSE for details.

About

Manage asynchronous operations, timing, error handling, detecting intersection of elements, and caching easily and declaratively (One of TanStack Query community resources)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 96.9%
  • JavaScript 3.1%