useUrlTrigger

Write-only URL state updates for triggers.

Use useUrlTrigger for buttons or actions that only need to write to the URL without reading it.

The hook writes through TanStack Router navigation and stays route-agnostic, so it works well for toolbar actions, detached triggers, and menu items.

Usage

import { useUrlTrigger } from "@tilt-legal/cubitt-components/utilities/hooks";

export function TriggerButton() {
  const { trigger } = useUrlTrigger({
    paramName: "dialog",
    paramSetValue: "true",
  });

  return <button onClick={() => void trigger()}>Open</button>;
}

Router registration

With TanStack Router registration in place, paramName narrows to known search keys from your app's route tree. TanStack Start/file-based apps usually get this automatically; manual router setups should use the standard Register declaration once in app setup.

API

OptionTypeDescriptionDefault
paramNamestringURL parameter name. Narrows to known search keys when your router is registered.-
paramSetValuestringValue to set in the URL when triggered"true"
paramThrottlenumberThrottle URL writes in milliseconds-
paramDebouncenumberDebounce URL writes in milliseconds-

On this page