ktor-svelte 1.0
1.0 adds no headline feature. It is the release where the API stops moving, and where everything that was already there got tested harder than before.
What 1.0 promises
From this release on, ktor-svelte follows semantic versioning:
- a patch release such as 1.0.1 only fixes bugs
- a minor release such as 1.1.0 adds features and keeps your build working
- only a major release can remove or rename something, and it comes with an upgrade guide
The promise covers the Kotlin API outside packages named internal, and the settings and tasks of the Gradle plugin.
What changed on the way
The API was cleaned up one last time. Enum constants use one casing, a deprecated alias is gone, and classes that were public by accident are closed. Most apps compile unchanged. The upgrade guide for 1.0 lists every step.
A third example app. examples/showcase is a team board with sign in, roles, an admin area, a database with migrations, file uploads, search, paging, themes and two languages. Building it and clicking through it is how most of the bugs below were found.
Bugs fixed. Each of these was found by using ktor-svelte the way an app does, not by reading its code:
- A nullable property such as
val assignee: UserRef?was typed as a second TypeScript typeUserRef2. It isUserRef | nullnow. call.messagesandcall.themefailed with "i18n is not configured" while the app ran undersvelteDevAll.- With
transport { compression() }, precompressed pages and assets were compressed a second time on every request. - Text typed into an input with
use:fieldbefore the page became interactive was wiped. - The dev proxy answered 502 to clients that offer an HTTP/2 upgrade, such as Java's
HttpClient. - A compressed request body could unpack far beyond
maxApiBodySize. The limit now also covers the unpacked size. - A path with a broken percent escape, and a
Hostheader that cannot be parsed, answered 500. They answer 400 now.
The setup script is more careful. It does nothing until it has been downloaded completely, and it refuses a version that does not look like one.
How it was tested
- End to end. Every example is built into a JAR and tested over HTTP. For the showcase that covers sessions, cookie flags, roles, uploads, paging, rate limits and data that survives a hard stop.
- In real browsers. The showcase JAR is driven by Playwright in Chromium, Firefox and WebKit: forms, uploads, downloads, both languages, themes and the Content-Security-Policy.
- Accessibility. Every page of the showcase passes the axe checks for WCAG 2.1 A and AA, in a light and in a dark theme.
- Development mode. A test starts
svelteDevAll, edits a Svelte file and a Kotlin file, and checks that the open page updates and the app restarts. - Every package manager. Bun, npm, pnpm and Yarn each install, build and test an example in CI.
- Upgrades. A project created by release 0.12.0 is switched to the current code and has to build, on every change.
- A pentest. About 150 hand-written requests against the showcase JAR: path traversal, redirects, the Host header, the origin check, request bodies, injection, access control, session cookies and sign in. The three weaknesses it found are in the list above. The security page says what ktor-svelte protects and what it leaves to you.
- Static analysis. CodeQL scans the Kotlin, the TypeScript and the workflows on every pull request.
If you skipped 0.12
0.12 made IntelliJ a better place to work:
- Compiler errors and browser stack traces in the
svelteDevAllconsole are links to the file and line. - New run configurations debug the frontend, and start the app with a debugger attached in one click.
- New projects get their run configurations and live templates set up without a second command.
Upgrading
- Change the plugin version to
1.0.0. - Run
./gradlew svelteSync, and./gradlew svelteGenerateTsif you usegenerateTs. Commit what changed. - If the build does not compile, the upgrade guide for 1.0 has the step you need.
Good to know
- The built-in messages for
@JsonSchemabounds are English. Write your own rule withcheckfor other wording. - SvelteKit 3 does not load TypeScript 7 yet. Stay on TypeScript 6 in your frontend.
- The dev proxy forwards HTTP only. Hot reload still works, because Vite's client connects to Vite directly.
- There is no server-side rendering, by design. The FAQ explains why and what to use instead.
The full list of changes is in the changelog.