React Router API Reference
    Preparing search index...

    Function unstable_useRouterState

    • A unified hook for reading router state: current (active) and in-flight (pending) locations, search params, params, matches, and navigation type.

      This hook consolidates the information you used to get from useLocation, useSearchParams, useParams, useMatches, useNavigation, and useNavigationType into a single hook.

      Returns unstable_RouterState

      The current router state with active and pending variants

      import { unstable_useRouterState as useRouterState } from "react-router";

      let { active, pending } = unstable_useRouterState();

      // Active is always populated with the current location
      active.location; // replaces `useLocation()`
      active.searchParams; // replaces `useSearchParams()[0]`
      active.params; // replaces `useParams()`
      active.matches; // replaces `useMatches()`
      active.type; // replaces `useNavigationType()`

      // Pending is only populated during a navigation
      pending.location; // replaces `useNavigation().location`
      pending.searchParams; // equivalent to `new URLSearchParams(useNavigation().search)`
      pending.params; // Not directly accessible today
      pending.matches; // Not directly accessible today
      pending.type; // Not directly accessible today
      pending.state; // replaces `useNavigation().state`
      pending.formMethod; // replaces useNavigation().formMethod
      pending.formAction; // replaces useNavigation().formAction
      pending.formEncType; // replaces useNavigation().formEncType
      pending.formData; // replaces useNavigation().formData
      pending.json; // replaces useNavigation().json
      pending.text; // replaces useNavigation().text

      unstable_useRouterState

      framework

      data