useRevalidator
Get the active router revalidation function.
Compatibility
Import from @kasperrt/smolter/react @kasperrt/smolter/preact
Signature
function useRevalidator(): Router["revalidate"];Parameters
The hook takes no arguments. The returned function accepts RevalidateOptions: route (one route ID/path pattern or an array), reason (manual by default), and optional mutation context. The legacy reason/context arguments remain supported.
Returns
An async function resolving after revalidation.
Usage
Import this API from one of the entry points listed above. Keep server and build helpers in their dedicated subpaths.
const revalidate = useRevalidator();
await revalidate({ route: "/tasks/:id" });
await revalidate({ route: "root" });
await revalidate({ route: ["root", "/tasks/:id"] });Behavior and edge cases
Without targets, refreshes the active page, loaded fetchers, and registered root/layout data. Targets restrict that set; inactive or unknown routes do not load. shouldRevalidate can skip manual refreshes too. Resolves after selected work finishes. This API returns a function.