Skip to main content


React component that implements autoscroll to page start or to the anchor on page on SPA-navigations

The behaviour is similar to the react-router


First install @tramvai/module-autoscroll:

yarn add @tramvai/module-autoscroll

And add AutoscrollModule to the modules list:

import { createApp } from '@tramvai/core';
import { AutoscrollModule } from '@tramvai/module-autoscroll';

name: 'tincoin',
modules: [AutoscrollModule],



behavior: smooth is not supported by every browser (e.g. doesn't work in Safari). In this case you can use polyfill smoothscroll-polyfill that you should add to your app.

How to

Disable autoscroll for page

If you need to disable autoscroll on the specific pages you can specify parameter navigateState.disableAutoscroll = true to the navigate call:

import { useNavigate } from '@tramvai/module-router';

function Component() {
const navigateToWithoutScroll = useNavigate({
url: '/url/',
navigateState: { disableAutoscroll: true },

return <Button onClick={navigateToWithoutScroll} />;