sveltejs/kit · warning

`data-sveltekit-${name}="true"` has been replaced with `data

Error message

`data-sveltekit-${name}="true"` has been replaced with `data-sveltekit-reset="false"`

What it means

SvelteKit replaced the `data-sveltekit-keepfocus` and `data-sveltekit-noscroll` attributes with a single `data-sveltekit-reset="false"` attribute that keeps focus and prevents scrolling on navigation. When resolving router options from the DOM in DEV, `get_router_options` warns (once per element) if it finds any of the legacy attributes, telling you the replacement. The legacy attributes are ignored.

Source

Thrown at packages/kit/src/runtime/client/utils.js:181

	/** @type {ValidLinkOptions<'reload'> | null} */
	let reload = null;

	/** @type {ValidLinkOptions<'replacestate'> | null} */
	let replace_state = null;

	/** @type {ValidLinkOptions<'reset'> | null} */
	let reset = null;

	/** @type {Element} */
	let el = element;

	while (el && el !== document.documentElement) {
		if (DEV) {
			for (const name of ['keepfocus', 'noscroll']) {
				const value = el.getAttribute(`data-sveltekit-${name}`);
				if (value !== null && !warned.has(el)) {
					warned.add(el);
					console.warn(
						`\`data-sveltekit-${name}="true"\` has been replaced with \`data-sveltekit-reset="false"\``
					);
					console.log(el);
				}
			}
		}

		if (preload_code === null) preload_code = link_option(el, 'preload-code');
		if (preload_data === null) preload_data = link_option(el, 'preload-data');
		if (reload === null) reload = link_option(el, 'reload');
		if (replace_state === null) replace_state = link_option(el, 'replacestate');
		if (reset === null) reset = link_option(el, 'reset');

		el = /** @type {Element} */ (parent_element(el));
	}

	/** @param {string | null} value */
	function get_option_state(value) {

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Remove `data-sveltekit-keepfocus="true"` and `data-sveltekit-noscroll="true"` from your elements/layouts
  2. Add `data-sveltekit-reset="false"` where the old keepfocus/noscroll behavior is wanted
  3. Search the codebase: `grep -r 'data-sveltekit-keepfocus\|data-sveltekit-noscroll'`

Example fix

<!-- before -->
<a href="/search" data-sveltekit-noscroll="true" data-sveltekit-keepfocus="true">Search</a>
<!-- after -->
<a href="/search" data-sveltekit-reset="false">Search</a>
Defensive patterns

Strategy: validation

Validate before calling

if (document.querySelector('[data-sveltekit-keepfocus],[data-sveltekit-noscroll]')) console.warn('legacy data-sveltekit attributes found — use data-sveltekit-reset="false"');

Prevention

When it happens

Trigger: An element in the component tree (walked up from a link to `document.documentElement`) has `data-sveltekit-keepfocus="true"` or `data-sveltekit-noscroll="true"`, and a navigation resolves router options through that element in DEV.

Common situations: Apps migrated from older SvelteKit versions whose `<a>` tags or layouts still carry keepfocus/noscroll attributes; copied snippets from old tutorials or documentation.

Related errors


AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02). Data as JSON: /api/errors/18151580a820539f. Report an issue: GitHub.