Initial data plugin for Spoosh - show data immediately before fetch completes.
Documentation · Requirements: TypeScript >= 5.0 · Peer Dependencies: @spoosh/core
npm install @spoosh/plugin-initial-dataimport { Spoosh } from "@spoosh/core";
import { initialDataPlugin } from "@spoosh/plugin-initial-data";
const spoosh = new Spoosh<ApiSchema, Error>("/api").use([initialDataPlugin()]);
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) |