sveltejs/kit · warning
`pushState(...)` is deprecated. Use `goto(url, { state, shal
Error message
`pushState(...)` is deprecated. Use `goto(url, { state, shallow: true })` instead. What it means
SvelteKit's client runtime emits this DEV-only console warning when the exported `pushState(url, state)` function is called. `pushState` has been deprecated in favor of the unified `goto()` API with `{ state, shallow: true }` options, which performs the same shallow navigation while pushing history state. It is a migration notice, not a failure; the call still executes.
Source
Thrown at packages/kit/src/runtime/client/client.js:2916
return;
}
await load_route_nodes(route);
}
/**
* Programmatically create a new history entry with the given `page.state`. Used for [shallow routing](https://svelte.dev/docs/kit/shallow-routing).
*
* @deprecated Use `goto(url, { state, shallow: true })` instead.
* @param {string | URL} url
* @param {App.PageState} state
* @returns {Promise<void>}
*/
export async function pushState(url, state) {
if (DEV && !warned_on_push_state) {
warned_on_push_state = true;
console.warn(
'`pushState(...)` is deprecated. Use `goto(url, { state, shallow: true })` instead.'
);
}
const intent = await resolve_intent(url, 'pushState');
await update_state(
intent,
state,
{ replace: false, persist_state: false, reset: false },
'pushState'
);
}
/**
* Programmatically replace the current history entry with the given `page.state`. Used for [shallow routing](https://svelte.dev/docs/kit/shallow-routing).
*
* @deprecated Use `goto(url, { state, shallow: true, replace: true })` instead.View on GitHub (pinned to 03f1687fe6)
Solutions
- Replace `pushState(url, state)` with `goto(url, { state, shallow: true })`
- Verify the pushed state is still read via `page.state` after the switch
- Update any documentation/tests referencing pushState
Example fix
// before
import { pushState } from '$app/navigation';
pushState('/?modal=open', { modal: true });
// after
import { goto } from '$app/navigation';
goto('/?modal=open', { state: { modal: true }, shallow: true }); Defensive patterns
Strategy: validation
Validate before calling
if (DEV && 'pushState' in navigationModule) console.warn('migrate to goto'); // or simply avoid importing pushState Type guard
const usesPushState = (src) => /\bpushState\s*\(/.test(src);
Prevention
- Never import pushState/replaceState from $app/navigation in new code
- Use goto with { state, shallow: true } for shallow routing
- Add a lint rule banning pushState/replaceState identifiers
When it happens
Trigger: Calling `pushState(url, state)` imported from `@sveltejs/kit` in client-side code (e.g. inside an event handler or `load`/action) during development, the first time it is used per page load.
Common situations: Apps upgraded from older SvelteKit versions that used `pushState`/`replaceState` for shallow routing (e.g. opening modals/filters without a server round-trip) and have not migrated to the new `goto` options.
Understand the failure class
Background: "is deprecated and will be removed" — deprecation warnings for old API names, keywords, and options, and how to migrate before the removal release — this error's family across 29 libraries.
Related errors
- `replaceState(...)` is deprecated. Use `goto(url, { state, s
- Reading `config.kit` inside adapters is deprecated — it shou
- The `${keypath}` option is deprecated, and will be removed i
- `$app/environment` is deprecated, use `$app/env` instead
- `data-sveltekit-${name}="true"` has been replaced with `data
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/00d585da2932ecd8.
Report an issue: GitHub.