Initial data plugin for Spoosh - show data immediately before fetch completes
npm install @spoosh/plugin-initial-dataInitial data plugin for Spoosh - show data immediately before fetch completes.
Documentation · Requirements: TypeScript >= 5.0 · Peer Dependencies: @spoosh/core
``bash`
npm install @spoosh/plugin-initial-data
`typescript
import { Spoosh } from "@spoosh/core";
import { initialDataPlugin } from "@spoosh/plugin-initial-data";
const client = new Spoosh
const { data, isInitialData } = useRead((api) => api("posts").GET(), {
initialData: prefetchedPosts,
});
const { data } = useRead((api) => api("posts").GET(), {
initialData: prefetchedPosts,
refetchOnInitialData: false,
});
`
| Option | Type | Default | Description |
| ---------------------- | --------- | ------- | --------------------------------------------- |
| initialData | TData | - | Data to show immediately on first mount |refetchOnInitialData
| | boolean | true | Whether to refetch after showing initial data |
| Property | Type | Description |
| --------------- | --------- | ---------------------------------------------------------- |
| isInitialData | boolean | true` if currently showing initial data (not yet fetched) |