SvelteKit 3 just works on Netlify
By Steven Van ·
Upgrade with one migration command; the main thing to watch is the new #lib import alias, which needs explicit file paths.
SvelteKit 3 works on Netlify from day one, according to Netlify's changelog. Existing projects can upgrade with npx sv migrate sveltekit-3, which handles most of the mechanical changes, including moving config and updating imports.
Highlights of the release:
- Vite 8 is now required, with faster builds powered by Rolldown.
- SvelteKit config moves from svelte.config.js into vite.config.ts, so Vite plugins can read it right away.
- Explicit environment variables are stable. They are declared in src/env.ts, with each marked public or private and resolved at build time or at app boot, plus validation and type safety.
- The $lib alias becomes #lib, using Node's subpath imports.
- Shallow routing is built into goto() via shallow: true, replacing pushState and replaceState.
- All errors, including ones thrown with error(...), now go through the handleError hook.
- $service-worker is replaced by imports from $app/env, $app/paths and $app/manifest.
- Tracing support has moved out of the experimental namespace.
The #lib change is the one most projects are likely to hit. Directory imports without an explicit file no longer resolve, so $lib/utils becomes #lib/utils/index.ts. If a build fails after upgrading with a module resolution error, check for #lib imports that point to a directory or leave off the file extension.
New sites can start from the SvelteKit on Netlify doc, and the official migration guide covers the full list of changes.