React Router API Reference
    Preparing search index...

    Type Alias ScrollRestorationProps

    ScrollRestorationProps: ScriptsProps & {
        getKey?: GetScrollRestorationKeyFunction;
        storageKey?: string;
    }

    Type declaration

    • OptionalgetKey?: GetScrollRestorationKeyFunction

      A function that returns a key to use for scroll restoration. This is useful for custom scroll restoration logic, such as using only the pathname so that later navigations to prior paths will restore the scroll. Defaults to location.key. See GetScrollRestorationKeyFunction.

      <ScrollRestoration
      getKey={(location, matches) => {
      // Restore based on a unique location key (default behavior)
      return location.key

      // Restore based on pathname
      return location.pathname
      }}
      />
    • OptionalstorageKey?: string

      The key to use for storing scroll positions in sessionStorage. Defaults to "react-router-scroll-positions".