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
| Option | Type | Description | Default |
|---|---|---|---|
paramName | string | URL parameter name. Narrows to known search keys when your router is registered. | - |
paramSetValue | string | Value to set in the URL when triggered | "true" |
paramThrottle | number | Throttle URL writes in milliseconds | - |
paramDebounce | number | Debounce URL writes in milliseconds | - |