next-restore-scroll-position
TypeScript icon, indicating that this package has built-in type declarations

1.0.9 • Public • Published

Restore scroll position in NextJS

Restores scroll position when navigating back and forth in NextJS.

Installation

yarn add next-restore-scroll-position
npm i next-restore-scroll-position

Usage

import { useScrollRestoration } from 'next-restore-scroll-position';

function App() { // This needs to be NextJS App Component
    const router = useRouter();
    useScrollRestoration(router);
}

You can also disable the scroll restoration by passing enabled property

import { useScrollRestoration } from 'next-restore-scroll-position';

function App() { // This needs to be NextJS App Component
    const router = useRouter();
    useScrollRestoration(router, {enabled: false});
}

Peer dependencies

  • React 16 or up
  • Next 13

Dependencies (0)

    Dev Dependencies (4)

    Package Sidebar

    Install

    npm i next-restore-scroll-position

    Weekly Downloads

    298

    Version

    1.0.9

    License

    ISC

    Unpacked Size

    12.4 kB

    Total Files

    9

    Last publish

    Collaborators

    • michalszorad