sveltejs/kit · error

The `goto(..., { noScroll: true, keepFocus: true })` options

Error message

The `goto(..., { noScroll: true, keepFocus: true })` options have been replaced by `reset: false`

What it means

The legacy goto options noScroll and keepFocus were replaced by the single `reset: false` option. SvelteKit throws immediately when it sees either removed key so behavior is explicit rather than silently changing. Note `replaceState` is only deprecated (warned), while noScroll/keepFocus hard-fail.

Source

Thrown at packages/kit/src/runtime/client/client.js:2686

 *
 * `goto` is intended for navigations to routes that belong to the app, and will reject if a route cannot be resolved.
 * For external URLs, use `window.location = url` to perform a full-page navigation instead of calling `goto(url)`.
 *
 * @param {string | URL} url Where to navigate to. Note that if you've set [`config.paths.base`](https://svelte.dev/docs/kit/configuration#paths) and the URL is root-relative, you need to prepend the base path if you want to navigate within the app.
 * @param {GotoOptions} [opts] Options related to the navigation
 * @returns {Promise<void>}
 */
export async function goto(url, opts = {}) {
	if (DEV) {
		if ('replaceState' in opts && !warned_on_replace_state) {
			warned_on_replace_state = true;
			console.warn(
				`The \`goto(..., { replaceState: ${opts.replaceState} })\` option has been deprecated in favour of \`replace\``
			);
		}

		if ('noScroll' in opts || 'keepFocus' in opts) {
			throw new Error(
				`The \`goto(..., { noScroll: true, keepFocus: true })\` options have been replaced by \`reset: false\``
			);
		}
	}

	const replace = opts.replace ?? opts.replaceState ?? false;

	const intent = await resolve_intent(url, 'goto');

	if (opts.shallow) {
		return update_state(
			intent,
			opts.state ?? {},
			{
				replace,
				persist_state: opts.persistState ?? false,
				reset: opts.reset ?? false
			},

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Replace { noScroll: true, keepFocus: true } with { reset: false }
  2. Remove noScroll/keepFocus keys and rely on default reset behavior
  3. Also migrate deprecated replaceState to the `replace` option

Example fix

// before
await goto('/dashboard', { noScroll: true, keepFocus: true });
// after
await goto('/dashboard', { reset: false });
Defensive patterns

Strategy: validation

Validate before calling

function assertGotoOptions(opts) {
  if ('noScroll' in opts || 'keepFocus' in opts) {
    throw new Error('Use { reset: false } instead of noScroll/keepFocus');
  }
}
assertGotoOptions({ reset: false });

Prevention

When it happens

Trigger: Calling goto(url, { noScroll: true }) or goto(url, { keepFocus: true }) — any presence of these keys in the options object throws, regardless of value.

Common situations: Upgrading SvelteKit from a version before the goto options rework; copying old tutorial/snippet code; migrating libraries that wrapped goto with legacy options.

Related errors


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