{"record":{"id":"00d585da2932ecd8","repo":"sveltejs/kit","slug":"pushstate-is-deprecated-use-goto-url-s","errorCode":null,"errorMessage":"`pushState(...)` is deprecated. Use `goto(url, { state, shallow: true })` instead.","messagePattern":"`pushState\\(\\.\\.\\.\\)` is deprecated\\. Use `goto\\(url, (.+?)\\)` instead\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/kit/src/runtime/client/client.js","lineNumber":2916,"sourceCode":"\n\t\treturn;\n\t}\n\n\tawait load_route_nodes(route);\n}\n\n/**\n * Programmatically create a new history entry with the given `page.state`. Used for [shallow routing](https://svelte.dev/docs/kit/shallow-routing).\n *\n * @deprecated Use `goto(url, { state, shallow: true })` instead.\n * @param {string | URL} url\n * @param {App.PageState} state\n * @returns {Promise<void>}\n */\nexport async function pushState(url, state) {\n\tif (DEV && !warned_on_push_state) {\n\t\twarned_on_push_state = true;\n\t\tconsole.warn(\n\t\t\t'`pushState(...)` is deprecated. Use `goto(url, { state, shallow: true })` instead.'\n\t\t);\n\t}\n\n\tconst intent = await resolve_intent(url, 'pushState');\n\n\tawait update_state(\n\t\tintent,\n\t\tstate,\n\t\t{ replace: false, persist_state: false, reset: false },\n\t\t'pushState'\n\t);\n}\n\n/**\n * Programmatically replace the current history entry with the given `page.state`. Used for [shallow routing](https://svelte.dev/docs/kit/shallow-routing).\n *\n * @deprecated Use `goto(url, { state, shallow: true, replace: true })` instead.","sourceCodeStart":2898,"sourceCodeEnd":2934,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/client/client.js#L2898-L2934","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nimport { pushState } from '$app/navigation';\npushState('/?modal=open', { modal: true });\n// after\nimport { goto } from '$app/navigation';\ngoto('/?modal=open', { state: { modal: true }, shallow: true });","handlingStrategy":"validation","validationCode":"if (DEV && 'pushState' in navigationModule) console.warn('migrate to goto'); // or simply avoid importing pushState","typeGuard":"const usesPushState = (src) => /\\bpushState\\s*\\(/.test(src);","tryCatchPattern":null,"preventionTips":["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"],"tags":["deprecation","shallow-routing","client","sveltekit"],"backgroundTag":"deprecated-api-usage","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}