react-router-scroll-to-top
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

react-router-scroll-to-top

npm Version npm downloads per week Minified size Open issues Open pull requests GitHub Stars CircleCI status Code scanning

ScrollToTop is a React component that scrolls to the top of a page when the current location gets changed. Since React Router doesn't provide out-of-the-box support for scroll restoration due to browsers having started handling it on their own, this package implements a component for scrolling to the top manually as it is given in React Router docs.

Usage

npm install react-router-scroll-to-top
import { ScrollToTop } from 'react-router-scroll-to-top';

const App = () => (
  <BrowserRouter>
    <ScrollToTop />
    <Routes>{/* routes */}</Routes>
  </BrowserRouter>
);

Read the documentation for more details. You can also play with a demo.

Support

If you like this package and want to support it, you can do it on Patreon

Package Sidebar

Install

npm i react-router-scroll-to-top

Weekly Downloads

217

Version

1.2.1

License

MIT

Unpacked Size

9.49 kB

Total Files

6

Last publish

Collaborators

  • dimazuien