SvelteKit config in vite.config, explicit env vars and new declaration tag support across the toolchain
This month brought a real shift in how SvelteKit projects are configured. You can now define your SvelteKit config directly inside vite.config.js
and skip svelte.config.js
entirely. We also got the first preview of explicit environment variables, which will eventually replace $env/*
modules in SvelteKit 3.
On top of that, the language tools and the sv
CLI both caught up with Svelte's new {const ...}
declaration tags, so the whole toolchain is now in sync.
Let's dive in!
What's new in SvelteKit
- You can now pass your SvelteKit config directly to the Vite plugin, so a separate
svelte.config.js
is no longer required, as a preview of how Kit 3 will require config to live invite.config.js
(2.62.0, Docs, #15944) - Experimental explicit environment variables let you declare and type your env vars in one place, as a preview of how
$env/*
will work in SvelteKit 3 (2.63.0, Docs, #15934) - Remote function commands can now receive
File
objects directly, so you can upload files without manually wrapping them inFormData
(2.64.0, Docs, #15978) - Remote queries can now refresh other queries, making it easier to invalidate related data after a mutation (2.65.0, Docs, #16012)
- Prerendered
.md
and.mdx
files are now precompressed alongside HTML, JS and CSS for faster delivery (2.66.0, Docs, #15893) - SvelteKit now warns when boolean fields in remote form schemas are not marked optional, which is a common cause of silent submit failures (2.66.0, Docs, #15804)
- The new
prerender.handleInvalidUrl
option lets you customize how invalid URLs found during crawling are reported (2.67.0, Docs, #16088) RemoteFormEnhanceInstance
andRemoteFormEnhanceCallback
are now exported types, so you can type your customenhance
callbacks directly (2.68.0, Docs, #15816)- Submitted
submit
fields now keep their value in the form action payload, which makes multi-button forms easier to handle on the server (2.68.0, Docs, #15979)
For all the features and bugfixes that landed this month, check out the SvelteKit / Adapter CHANGELOGs.
What's new in the Svelte CLI and Language Tools
- The Svelte CLI demo template now uses the new
{const ...}
declaration tag, so newly created projects show off the latest Svelte syntax (sv@0.16.0, #1110) sv create
now scaffolds projects against@sveltejs/kit
^2.62.0
and moves the Svelte config into the Vite plugin by default (sv@0.16.0, #1119)- A new experimental add-on lets you toggle experimental flags and opt into
@next
versions directly from the CLI (sv@0.16.0, #1121) - The
drizzle
andbetter-auth
add-ons now support SvelteKit's new explicit environment variables (sv@0.16.0, #1122) - New
defineEnv
andsvelteConfig
helpers in@sveltejs/sv-utils
make it easier to read and edit a project's Svelte config from add-ons (sv-utils@0.3.0) - The Svelte language server,
svelte-check
andsvelte2tsx
now understand Svelte 5's{const ...}
declaration tags (svelte-language-server@0.18.1/svelte-check@4.5.0/svelte2tsx@0.7.56, #3033) - CSS completions now work inside nested
