SvelteKit 1.0 migration guide (from SvelteKit alpha) #5774
Replies: 7 comments
-
Update
|
Beta Was this translation helpful? Give feedback.
-
Update
|
Beta Was this translation helpful? Give feedback.
-
Update
|
Beta Was this translation helpful? Give feedback.
-
Add
|
Beta Was this translation helpful? Give feedback.
-
Check for missing importsIf a layout/page component had a |
Beta Was this translation helpful? Give feedback.
-
Replace error
|
Beta Was this translation helpful? Give feedback.
-
File name changesThe router is now folder-based, not file-based. This means there's now only one way to describe a route. Here's how you define that there's a route
The same principle applies to parameterized routes:
The naming of the routing files has changed. They correspond as follows (assuming the first variant of the table above):
To summarize: All route files have a |
Beta Was this translation helpful? Give feedback.
-
General advice
We highly recommend to not directly update to 1.0 and instead go through the breaking changes one-by-one. This way, the migration instructions will be easier to follow and also be more correct - some of them might be slightly outdated since they are shadowed by subsequent changes.
If you're prior to version 1.0.0-next-406
New versions of SvelteKit include a design overhaul that will require some changes to your app. (You can read about the overall reasoning behind these changes in #5748.)
To begin migrating your app, run the following command:
You will need to do this before installing the new version! We recommend updating to the most recent version before these changes —
@sveltejs/[email protected]
— and ensuring that your app works with that version before running the migration.This will rename files inside your routes folder (see this comment to learn more about the changes), migrate some of the changes automatically and annotate your code with errors that link back to this page and tell you what needs to be manually updated. You can find these errors by searching your codebase for
@migration
.If you're after version 1.0.0-next-406
If you update to versions past that, there are some more breaking changes, which are described in more details with info on how to migrate in their respective PRs. Again, we advise you to do these step by step, always updating to the relevant
next-X
version, then migrate, then go to the nextnext-X
version, until you've reached 1.0:1.0.0-next.432
): Implement new layouts system #61741.0.0-next.454
): feature: Replacesveltekit:*
with valid HTML attributes likedata-sveltekit-*
#61701.0.0-next.455
): Prerendering overhaul #6392, [breaking]ssr/hydrate/router/prerender.default
are now configurable in+page(.server).js
and+layout(.server).js
#61971.0.0-next.472
): Form actions #64691.0.0-next.560
): renameprerendering
tobuilding
,remove config.kit.prerender.enabled
#77621.0.0-next.565
): Replacedata-sveltekit-prefetch
/prefetch(...)
/prefetchRoutes(...)
#7776invalid
tofail
(1.0.0-next.578
): [breaking] renameinvalid(...)
andValidationError
#80121.0.0-next.579
): Upgrade to Vite 4 #7543There may be small breaking changes inbetween those listed above. All have a meaningful error thrown with either direct migration instructions or a link to the PR which explains how to migrate.
For a list of all breaking changes: https://github.com/sveltejs/kit/pulls?q=is%3Apr+label%3A%22breaking+change%22+is%3Aclosed or https://github.com/sveltejs/kit/blob/master/packages/kit/CHANGELOG.md (breaking changes are marked with
[breaking]
)Upgrading to 1.0
Make sure to first upgrade to the last version before the 1.0 release that still has all the errors and warnings that help you with upgrading. That version is 1.0.0-next.588. They are removed from 1.0 onwards.
Beta Was this translation helpful? Give feedback.
All reactions