Skip to content

svelte: Update SvelteKit to v3 - #14906

Merged
Turbo87 merged 10 commits into
rust-lang:mainfrom
Turbo87:sveltekit-3
Oct 8, 2026
Merged

Turbo87 merged 10 commits into
rust-lang:mainfrom
Turbo87:sveltekit-3

Conversation

@Turbo87

@Turbo87 Turbo87 commented Oct 7, 2026

Copy link
Copy Markdown
Member

This updates SvelteKit to v3, together with @sveltejs/adapter-static v4 and @sveltejs/enhanced-img v1. The first commit only bumps the dependencies, and each following commit adapts one part of the app to a breaking change. The intermediate commits therefore do not build, but the individual adjustments are easier to review this way.

Most adjustments follow the migration guide: paths.origin replaces prerender.origin, tsconfig.json extends $app/tsconfig, external redirects pass external: true, and reset: false replaces the removed keepFocus and noScroll options of goto(). Since reset: false also skips the scroll reset, SearchForm scrolls to the top manually after a search, which the new e2e test covers.

SvelteKit 3 can apparently run the afterNavigate() callbacks of the initial navigation before the components have mounted, so SearchForm now focuses its input in onMount(). The same bug seems to affect the route announcer of SvelteKit too, which stays silent after the first client-side navigation. Two aria snapshots therefore no longer contain the announced page title.

Storybook does not fully support SvelteKit 3 yet, so the Storybook config defines a workaround for now.

Related

Turbo87 added 10 commits October 7, 2026 16:48
The existing test only covers that the search input keeps focus after pressing Enter. This test additionally ensures that the search results are shown from the top of the page, even when the form is submitted from a scrolled page.
This updates `@sveltejs/kit` to v3, `@sveltejs/adapter-static` to v4 and `@sveltejs/enhanced-img` to v1.
SvelteKit 3 removes the `prerender.origin` option in favor of `paths.origin`, and fails to load the configuration while it is still set.
SvelteKit 3 expects `tsconfig.json` to extend `$app/tsconfig` instead of the generated `.svelte-kit/tsconfig.json`. The `include` list is now explicit, since `$app/tsconfig` does not provide one, and the compiler options that `$app/tsconfig` already sets are removed.
SvelteKit 3 combines the removed `keepFocus` and `noScroll` options of `goto()` into a single `reset` option.
SvelteKit 3 rejects `redirect()` calls to external URLs unless they pass the `external` option. The documentation, repository and install redirects all point to other sites, so they now pass `external: true`.
Storybook removes the SvelteKit plugin that defines this constant, which breaks `$app/paths` in `storybook build` with SvelteKit 3. The Storybook config defines the constant until Storybook supports SvelteKit 3.
SvelteKit 3 removes the `keepFocus` option of `goto()`. Its replacement `reset: false` keeps the focus in the search input, but also skips the scroll reset, so the submit handler now scrolls to the top after the navigation.
SvelteKit 3 can run the `afterNavigate()` callbacks of the initial navigation before the component has mounted, so the search input on the front page was no longer focused. Focusing it in `onMount()` works regardless of that order, because SvelteKit 3 no longer resets the focus once an element other than `<body>` is focused.
SvelteKit 3 runs the `afterNavigate()` callbacks of the initial navigation before its route announcer has mounted, so the announcer stays empty after the first client-side navigation. The search and support tests make only one client-side navigation before their snapshots, which therefore no longer contain the announced page title.
@Turbo87
Turbo87 merged commit 49cabe4 into rust-lang:main Oct 8, 2026
22 of 23 checks passed
@Turbo87
Turbo87 deleted the sveltekit-3 branch October 8, 2026 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants