import { type DependencyList } from "react";
/** Options for {@link useFetch}. */
export interface UseFetchOptions {
    /**
     * Poll interval in milliseconds. When set to a positive number, the
     * hook re-fetches on a timer. Set to `false` or `0` to disable.
     *
     * The timer is paused while a fetch is already in flight to prevent
     * request piling on slow connections.
     */
    readonly refetchInterval?: number | false;
    /**
     * Stable string key for cross-mount caching.
     *
     * When provided (and a {@link FetchCacheProvider} is mounted above
     * this component), the hook reads cached data on mount to avoid a
     * loading skeleton, and writes fresh data to the cache on every
     * successful fetch.
     *
     * Pass `undefined` to opt out of caching for a given call.
     *
     * @example `session:${id}`
     * @example `session-executions:${sessionId}`
     */
    readonly cacheKey?: string;
}
/** Return value of {@link useFetch}. */
export interface UseFetchReturn<T> {
    /** The most recently resolved data, or `initialData` before the first success. */
    readonly data: T;
    /**
     * `true` only when no data has been fetched yet (first load).
     * Once data arrives, subsequent refetches keep this `false`.
     */
    readonly isLoading: boolean;
    /**
     * `true` while a background refetch is in flight and stale data is
     * being shown. Always `false` during the initial load.
     */
    readonly isRefetching: boolean;
    /** Error from the last failed request, or `null` when healthy. */
    readonly error: Error | null;
    /** Imperatively trigger a re-fetch. Stale data remains visible. */
    readonly refetch: () => void;
}
/**
 * Generic data-fetching hook with stale-while-revalidate semantics.
 *
 * - Pass `null` for `fetchFn` to disable fetching (idle state).
 * - On the **first** fetch, `isLoading` is `true` so consumers can
 *   show a skeleton.
 * - On **subsequent** fetches (refetch or dep change after first success),
 *   `isLoading` stays `false` and `isRefetching` becomes `true` —
 *   existing data remains visible, preventing skeleton flash.
 * - On error during a refetch, stale data is preserved.
 *
 * @param fetchFn  Async function that returns data, or `null` to skip.
 * @param deps     Dependency list — a new fetch fires when any dep changes.
 * @param initialData  Value returned before the first successful fetch.
 * @param options  Optional configuration (e.g. polling interval).
 *
 * @internal Not part of the public `@stigmer/react` API.
 */
export declare function useFetch<T>(fetchFn: (() => Promise<T>) | null, deps: DependencyList, initialData: T, options?: UseFetchOptions): UseFetchReturn<T>;
//# sourceMappingURL=useFetch.d.ts.map