useNavigationType
Read whether the current application history entry came from POP, PUSH, or REPLACE.
Compatibility
Import from @kasperrt/smolter/react @kasperrt/smolter/preact
Signature
function useNavigationType(): NavigationType;Parameters
Takes no arguments and requires RouterProvider. The browser navigation integration installed by mountApplication maintains the value.
Returns
Returns the NavigationType string POP, PUSH, or REPLACE. The initial value is POP. This describes history behavior, not whether a loader or action is currently pending.
Example
Read the navigation type where the UI needs to distinguish a replacement from a new history entry.
import { useNavigationType } from "@kasperrt/smolter/preact";
export function HistoryStatus() {
const type = useNavigationType();
return <span>History action: {type}</span>;
}Commit timing
History state is published when the navigation integration sees an idle snapshot. With a retained view this can follow the underlying request completion. A standalone RouterProvider without that integration keeps the store’s initial value.