smolter
Types

ShouldRevalidateFunctionArgs

URLs, reason, and mutation details used to decide whether to reload.

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

type ShouldRevalidateFunctionArgs = RevalidationArgs;

Contract

Aliases RevalidationArgs. Contains url, currentUrl, nextUrl, defaultShouldRevalidate, and reason (manual, action, or navigation). Action-triggered refreshes can also supply formMethod, formAction, formData, and actionResult.

import type { ShouldRevalidateFunctionArgs } from "@kasperrt/smolter/preact";

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

  return args.defaultShouldRevalidate;
}

Usage and limits

Return false to skip the selected loader. During manual or action revalidation, the current and next URLs describe the route being refreshed. Selecting route IDs limits the candidates first; shouldRevalidate then decides whether each candidate actually reloads.

View implementation ↗