SvelteKit 3 reached stable on October 2, 2026, after a run of release candidates that spread the breaking changes out over several weeks. Two months on, most migration tickets filed against v2 projects cluster around a handful of spots: configuration moving into Vite, the renamed $lib alias, and the removal of the $app/stores module. This guide walks through the migration path recommended by the Svelte team, backed by a command that automates a good part of the work.
Before migrating: stay on the latest 2.x release
The official guide insists on a step that’s tempting to skip: first bring the project up to the latest available 2.x release. That version surfaces targeted deprecation warnings for every usage that will break in v3, turning the migration into a checklist instead of a bug hunt after the fact.
Next comes the automation command, which covers part but not all of the breaking changes:
npx sv migrate sveltekit-3Minimum required versions
SvelteKit 3 raises the floor on several dependencies. A project that hasn’t touched its tooling since v2 shipped will usually need to bump everything at once.
| Dependency | Typical v2 minimum | Required in v3 |
|---|---|---|
| Node.js | 18.13 | 22.17 |
| TypeScript | 5.x | 6.0 |
| Svelte | 4.x or 5.0 | 5.57.1 |
| Vite | 5.x | 8.0.12 |
| @sveltejs/vite-plugin-svelte | 3.x or 4.x | 7.x |
Configuration moves out of svelte.config.js
svelte.config.js is no longer read by SvelteKit 3. Every option that used to live under kit.* becomes a top-level option of the sveltekit() plugin, directly in vite.config.js. Several options disappear along the way (files.lib, vitePlugin, preloadStrategy, csrf.checkOrigin), replaced by more explicit equivalents such as paths.origin or csrf.trustedOrigins.
// vite.config.js
import { sveltekit } from '@sveltejs/kit/vite';
export default {
plugins: [
sveltekit({
paths: { origin: 'https://example.com' },
csrf: { trustedOrigins: ['https://example.com'] },
}),
],
};Aliases and modules: the roughest patch
Almost every SvelteKit project imports from $lib, which makes it the most common friction point. In v3, the alias has to be declared explicitly in the imports field of package.json as #lib and #lib/*, file extensions included in the paths. $app/stores is gone in favor of $app/state, dropping the $ prefix on its properties. $service-worker is split across three modules ($app/env, $app/manifest, $app/paths), and $app/environment becomes $app/env. The $env/... modules aren’t removed but deprecated, in favor of $app/env/private and $app/env/public: a project that keeps them still works, but logs a warning on every build.
| Import in SvelteKit 2 | Equivalent in SvelteKit 3 |
|---|---|
$lib/... | #lib/... (declared in package.json) |
$app/stores | $app/state (no $ prefix on properties) |
$app/environment | $app/env |
$service-worker | $app/env, $app/manifest, $app/paths |
$env/static/*, $env/dynamic/* | $app/env/private, $app/env/public (deprecated, not removed) |
The sv migrate sveltekit-3 command automatically rewrites $lib imports to #lib, but it doesn’t touch navigation or adapters: both need a manual check.
Navigation, errors, and cookies
Replacing pushState/replaceState with goto(..., { shallow: true }) is the easiest breaking change to miss silently: the code keeps appearing to work until a nested navigation misbehaves. invalidateAll becomes refreshAll, and the keepFocus/noScroll options of goto merge into reset: false. On the error side, error() only accepts a string as its second argument now; extra properties move to a third argument. Cookies move to v2 of the cookie library: names must be ASCII, and the default path becomes '/'.
edge runtime, and the Cloudflare adapter requires Wrangler 4.67 or later: check those versions before migrating a live project.Remote functions: the optional work worth planning for
Remote functions aren’t on by default: they need experimental.remoteFunctions declared in the plugin’s configuration. Once enabled, they place one precise constraint on query-type functions: they can no longer read event.url, event.params, or event.route, since these functions are designed to be callable independently of the request context that triggered them. Projects that relied on those properties to vary a response based on the current URL need to move that logic to the caller, passing the needed parameters explicitly into the remote function instead of reading them off the event.
// src/lib/data.remote.js
import { query } from '$app/server';
// Wrong in v3: reading event.params inside a query
export const getProduct = query(async () => {
// pass an explicit argument instead of event.params.id
});Common mistakes seen on already-migrated projects
Three patterns show up most often in migration reports filed since October. First, a svelte.config.js that doesn’t get fully emptied: SvelteKit 3 ignores the file, but a third-party tool (editor, extension, an in-house build script) sometimes keeps reading it, producing a phantom configuration that no longer matches what’s actually active in vite.config.js. Second, calls to pushState or replaceState hidden inside an internal dependency or a component shared across several routes, which don’t throw any build error and only surface during a manual navigation test. Third, end-to-end tests that checked a Last-Modified header on static assets served by the Node adapter: that header is no longer sent in v3, which silently fails assertions written for v2.
A sensible migration order
The path that minimizes back-and-forth is: upgrade to the latest 2.x release and list the deprecation warnings, run npx sv migrate sveltekit-3, bump Node, TypeScript, Svelte, and Vite in package.json, move the configuration into vite.config.js, then manually check navigation, cookies, and the deployment adapter. Remote functions stay optional: enable them with experimental.remoteFunctions and avoid accessing event.url, event.params, or event.route in queries.
Key takeaways
SvelteKit 3 moves configuration into Vite, renames the $lib alias to #lib, and removes $app/stores in favor of $app/state. The sv migrate sveltekit-3 command automates most of these changes but leaves navigation, errors, and adapters to be checked by hand. The minimum versions (Node 22.17, TypeScript 6, Vite 8.0.12) often force a tooling upgrade before the application code is even touched.
On the two migrations I’ve run since the stable release, the sv migrate command handled most of the mechanical work in minutes; the time actually got lost on forgotten pushState calls buried in third-party code, which threw no error before reaching production. Checking navigation by hand isn’t optional — Simon Janvier.
Further reading: the official migration guide on svelte.dev, best read after our piece on the SvelteKit 3 stable release and our roundup of command-line tools for web development.
