main
Branches
main (2.15.1)dev
Versions
2.15.11.19.3v0.21.0
React Router v7 has been released. View the docs
useLocation
On this page

useLocation

Returns the current location object.

import { useLocation } from "@remix-run/react";

function SomeComponent() {
  const location = useLocation();
  // ...
}

Properties

location.hash

The hash of the current URL.

location.key

The unique key of this location.

location.pathname

The path of the current URL.

location.search

The query string of the current URL.

location.state

The state value of the location created by <Link state> or navigate.

Docs and examples licensed under MIT