Skip to Content
👀 Check out the changes in Suspensive v3. read more
DocumentationWhat is Suspensive?

Suspensive

Suspensive is a comprehensive collection of libraries designed to simplify and enhance the use of React Suspense. Suspensive contains several packages that provide components, hooks, and utilities to streamline the implementation of suspense-based features, error handling, and integrations with popular data fetching libraries.

Purpose

The Suspensive libraries address common challenges developers face when working with React Suspense, such as:

  • Managing loading states and timing
  • Implementing robust error boundaries
  • Integrating suspense with data fetching libraries
  • Coordinating multiple suspense and error boundaries
  • Creating viewport-aware components with suspense capabilities

By providing a unified, declarative API for these concerns, Suspensive helps developers create more resilient and better-structured React applications with significantly less boilerplate code.

Core Packages

Package Responsibilities


PackageDescriptionKey Features
@suspensive/reactCore suspense componentsErrorBoundary, Suspense, Delay, ErrorBoundaryGroup
@suspensive/react-domDOM-specific componentsInView
@suspensive/react-queryTanStack Query integration

SuspenseQuery, SuspenseInfiniteQuery, Version detection

@suspensive/jotaiJotai integrationuseAtomValue, useAtom, useSetAtom
@suspensive/codemodsMigration utilitiesAutomated code transformations

Architecture and Component Relationships

The Suspensive ecosystem is built on a foundation of core components from @suspensive/react, which are then extended and specialized by other packages:

Version Support and Compatibility

Suspensive is designed to work with:

  • React 18 and React 19
  • TanStack Query v4 and v5
  • Jotai v2

The library automatically adapts to the installed versions of these dependencies, providing a seamless developer experience regardless of which specific versions are being used in a project.

Data Flow Pattern

A central pattern in Suspensive is the handling of asynchronous states through React Suspense. Here’s how data flows through the system when using components like SuspenseQuery:

Key Benefits

  • Declarative Error Handling: Replace try/catch blocks with component-based error boundaries
  • Simplified Data Fetching: Integrate seamlessly with TanStack Query using suspense
  • Coordinated Error Management: Group and reset multiple error boundaries together
  • Controlled Loading States: Fine-tune loading indicators with timing controls
  • Viewport Awareness: Trigger loading or animations based on viewport visibility
Last updated on