smolter
Types

RevalidationArgs

The full synchronous shouldRevalidate argument.

Compatibility

ReactAvailable in this renderer's browser integration.
React SSRAvailable to this renderer's SSR integration; browser event handlers run after hydration.
PreactAvailable in this renderer's browser integration.
Preact SSRAvailable to this renderer's SSR integration; browser event handlers run after hydration.

Import from @kasperrt/smolter/react @kasperrt/smolter/preact

Signature

interface RevalidationArgs extends RevalidationContext {
  currentUrl: URL;
  nextUrl: URL;
  defaultShouldRevalidate: boolean;
  url: URL;
  reason: "manual" | "action" | "navigation";
}

Usage

The full synchronous shouldRevalidate argument. reason is manual, action, or navigation. currentUrl and nextUrl distinguish same-route navigation; action context is present after successful mutations. Return false to retain existing data.

export function shouldRevalidate({ currentUrl, nextUrl, reason }: RevalidationArgs) {
  if (reason === "navigation") return currentUrl.search !== nextUrl.search;

  return true;
}

Fields

currentUrl

currentUrl: URL;

nextUrl

nextUrl: URL;

defaultShouldRevalidate

defaultShouldRevalidate: boolean;

url

url: URL;

reason

reason: "manual" | "action" | "navigation";
View implementation ↗