Skip to main content
Version: v8.0.0

UseFetchOptionsType


Import
import { UseFetchOptionsType } from "@hyper-fetch/react"

Preview

type UseFetchOptionsType<R> = { bounce?: boolean; deepCompare?: (boolean | typeof isEqual); dependencies?: any[]; dependencyTracking?: boolean; disabled?: boolean; initialResponse?: NullableType<Partial<ExtractAdapterResolvedType<R>>>; keepPreviousData?: (auto | preserve | clean); refetchBlurred?: boolean; refetchOnBlur?: boolean; refetchOnFocus?: boolean; refetchOnReconnect?: boolean; refresh?: boolean; refreshTime?: number; revalidate?: boolean; suspense?: boolean } & ({ bounceTime?: number; bounceTimeout?: void; bounceType?: debounce } | { bounceTime?: number; bounceTimeout?: number; bounceType: throttle });

Structure

UseFetchOptionsType
NameTypeDescription
bounce
boolean

Enable/disable debouncing for often changing keys or refreshing, to limit requests to server.

deepCompare
boolean | typeof isEqual

Deep comparison function for hook to check for equality in incoming data, to limit rerenders.

dependencies
any[]

Refetch dependencies

dependencyTracking
boolean

If true it will rerender only when values used by our component gets changed. Otherwise it will rerender on any change.

disabled
boolean

Disable fetching

initialResponse
NullableType<Partial<ExtractAdapterResolvedType<R>>>

If cache is empty we can use placeholder data.

keepPreviousData
auto | preserve | clean

Controls what happens to the current state when the cache key changes (e.g. params or query params change).

  • "auto" (default) — Smart mode: clears state when URL params change (different resource), preserves state when only query params change (pagination/filtering).
  • "preserve" — Always keeps previous data visible until new data arrives.
  • "clean" — Always resets state to initial values when cache key changes.
refetchBlurred
boolean

Enable/disable data refresh if our tab is not focused(used by user at given time).

refetchOnBlur
boolean

Enable/disable data refresh if user leaves current tab.

refetchOnFocus
boolean

Enable/disable data refresh if user enters current tab.

refetchOnReconnect
boolean

Enable/disable data refresh if network is restored.

refresh
boolean

Enable/disable refresh data

refreshTime
number

Refresh data interval time

revalidate
boolean

If true it will refetch data in background no matter if we have it from cache.

suspense
boolean

Enable React Suspense mode. When true, the hook throws a Promise while loading, which is caught by the nearest Suspense boundary. The component re-renders with data available once the request resolves.