sveltejs/kit · warning
The `goto(..., { replaceState: ${opts.replaceState} })` opti
Error message
The `goto(..., { replaceState: ${opts.replaceState} })` option has been deprecated in favour of `replace` What it means
The `replaceState` option of `goto()` was renamed: use `replace: true` to replace the current history entry (the default also changed semantics across versions). DEV warns once when `replaceState` appears in the options object; it will be removed in a future major.
Source
Thrown at packages/kit/src/runtime/client/client.js:2680
/**
* Allows you to navigate programmatically to a given route, with control over details such as whether scroll and focus are reset
* (as they would be with a regular navigation) or preserved.
*
* Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) or the state change has been applied.
*
* `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,View on GitHub (pinned to 03f1687fe6)
Solutions
- Replace `{ replaceState: true }` with `{ replace: true }`
- If you intended push navigation, remove the option entirely (push is the default)
- Grep for `replaceState:` in goto call sites and update them
Example fix
// before
goto('/dashboard', { replaceState: true });
// after
goto('/dashboard', { replace: true }); Defensive patterns
Strategy: validation
Validate before calling
const opts = { replaceState: true };
if ('replaceState' in opts) { opts.replace = opts.replaceState; delete opts.replaceState; }
goto(url, opts); Type guard
function usesReplaceState(o) { return o != null && 'replaceState' in o; } Prevention
- Use `replace: true` for history-replacing navigation
- Grep for `replaceState:` in goto calls during upgrades
When it happens
Trigger: Calling `goto(url, { replaceState: true })` or `replaceState: false` from client code; the `goto` export in packages/kit/src/runtime/client/client.js warns when `'replaceState' in opts`.
Common situations: Redirect-after-login or filter updates that should not create a history entry, written against older SvelteKit 2 pre-release APIs.
Related errors
- The `goto(..., { invalidateAll: ${opts.invalidateAll} })` op
- The `update({ invalidateAll })` option has been deprecated i
- `export const snapshot` is deprecated. Use the `snapshot` he
- Can only disable scroll handling during navigation
- DEV: Cannot use `${caller}` with an external URL. Use `windo
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/8a2c84c87af47fdd.
Report an issue: GitHub.