All declarative components to use suspense on both CSR, SSR.
- Suspense (containing CSROnly mode)
- ErrorBoundary
- ErrorBoundaryGroup
- AsyncBoundary (containing CSROnly mode)
- Delay
- SuspensiveProvider
- HOC(Higher Order Component)s
- useAwait, Await, awaitClient (Experimental)
npm install @suspensive/react
pnpm add @suspensive/react
yarn add @suspensive/react
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>
)
Declarative apis to use @tanstack/react-query with suspense easily.
- useSuspenseQuery
- useSuspenseQueries
- useSuspenseInfiniteQuery
- QueryErrorBoundary, QueryAsyncBoundary
npm install @suspensive/react-query
pnpm add @suspensive/react-query
yarn add @suspensive/react-query
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({
queryKey,
queryFn,
})
return <>{query.data}</>
}
We provide Official Docs
See OFFICIAL DOCS
Concepts Visualization ready. You can see core concepts of Suspensive visually
See VISUALIZATION.
MIT © Suspensive. See LICENSE for details.