diff --git a/docs/router/api/router/RouterOptionsType.md b/docs/router/api/router/RouterOptionsType.md index 7127e1191e..c9f08956e2 100644 --- a/docs/router/api/router/RouterOptionsType.md +++ b/docs/router/api/router/RouterOptionsType.md @@ -411,3 +411,41 @@ If you want to configure to remount all route components upon `params` change, u ```tsx remountDeps: ({ params }) => params ``` + +### `scrollRestoration` property + +- Type: `boolean | ((opts: { location: ParsedLocation }) => boolean)` +- Optional +- Defaults to `false` +- If `true`, scroll restoration will be enabled. +- See the [Scroll Restoration Guide](../../guide/scroll-restoration.md/#scroll-restoration) for more information. + +--- + +### `getScrollRestorationKey` property + +- Type: `(location: ParsedLocation) => string` +- Optional +- Defaults to `(location) => location.href` +- A function that will be called to get the key for the scroll restoration cache. +- See the [Scroll Restoration Guide](../../guide/scroll-restoration.md/#custom-cache-keys) for more information. + +--- + +### `scrollRestorationBehavior` property + +- Type: `ScrollBehavior` (e.g., `'auto' | 'smooth'`) +- Optional +- Defaults to `'auto'` +- The default behavior for scroll restoration. +- See the [Scroll Restoration Guide](../../guide/scroll-restoration.md/#scroll-behavior) for more information. + +--- + +### `scrollToTopSelectors` property + +- Type: `Array Element | null | undefined)>` +- Optional +- Defaults to `['window']` +- An array of selectors that will be used to scroll to the top of the page in addition to `window`. +- See the [Scroll Restoration Guide](../../guide/scroll-restoration.md/#hashtop-of-page-scrolling) for more information. diff --git a/packages/router-core/src/router.ts b/packages/router-core/src/router.ts index c11cc86082..bc02db24e6 100644 --- a/packages/router-core/src/router.ts +++ b/packages/router-core/src/router.ts @@ -453,6 +453,7 @@ export interface RouterOptions< * If `true`, scroll restoration will be enabled * * @default false + * @link [Guide](https://tanstack.com/router/v1/docs/guide/scroll-restoration#scroll-restoration) */ scrollRestoration?: | boolean @@ -462,18 +463,21 @@ export interface RouterOptions< * A function that will be called to get the key for the scroll restoration cache. * * @default (location) => location.href + * @link [Guide](https://tanstack.com/router/v1/docs/guide/scroll-restoration#custom-cache-keys) */ getScrollRestorationKey?: (location: ParsedLocation) => string /** * The default behavior for scroll restoration. * * @default 'auto' + * @link [Guide](https://tanstack.com/router/v1/docs/guide/scroll-restoration#scroll-behavior) */ scrollRestorationBehavior?: ScrollBehavior /** * An array of selectors that will be used to scroll to the top of the page in addition to `window` * * @default ['window'] + * @link [Guide](https://tanstack.com/router/v1/docs/guide/scroll-restoration#hashtop-of-page-scrolling) */ scrollToTopSelectors?: Array Element | null | undefined)>