Skip to content

Everything ktor-svelte does ​

Every feature in one place, grouped by what you are doing. Each row links to the page that explains it, with snippets and every option.

Where it lives tells you where you turn a feature on or use it:

LabelMeans
Ktor plugininstall(Svelte) { } and helpers in your Kotlin routes, from ktor-svelte-server
Gradlesvelte { } in build.gradle.kts, or a Gradle task
Generated clientCode that ktor-svelte writes into your frontend, imported as #api, #routes or #components/...
Test kitktor-svelte-test, for Kotlin tests that drive a browser

A few rows say Recipe, Script, Docs, Release or This site instead: those are guides, the setup script, or things that happen outside your app.

New here? Start with Getting started or the tutorial. Looking for a whole solution, such as sign in or uploads? See the recipes.

Kotlin to TypeScript ​

Your Ktor routes and classes become a typed client, so the frontend breaks at compile time, not in production.

The generated client ​

FeatureWhat it doesWhere it lives
Generated TypeScriptTypes, services, validate(), empty() and enum objects for every route, written to frontend/src/lib/api with no npm dependenciesKtor plugin, Generated client
Exact typesKtor's compiler plugin reads receive and respond, or you describe a route by handGradle
Documentation in the editordescribe { } and @JsonSchema.Description become JSDoc, deprecations become @deprecated, and each function names its Kotlin fileGenerated client
DatesLocalDate, LocalTime, Instant and LocalDateTime become IsoDate, IsoTime and IsoDateTime, with safe convertersGenerated client
Shared constantsA Kotlin object with limits and lists, written to constants.tsKtor plugin, Generated client
IDs that cannot be mixed upA Kotlin value class becomes its own TypeScript typeGenerated client
Money and durationsExact Decimal values and Duration as text, with helpersKtor plugin, Generated client
Sealed classesA union with a type field and an exhaustive matchGenerated client
Resource routesresource registers list, get, create, update and delete with the names the client expectsKtor plugin
Routes nothing callssvelteVerifyApiRoutes lists API routes the frontend never usesGradle
What changed for callerssvelteApiChanges compares the API with another git revisionGradle
Generator playgroundPaste an OpenAPI document and see the TypeScript it becomes, in the browserThis site

Calling the API ​

FeatureWhat it doesWhere it lives
Typed calls and errorsapi.notes.list(), isApiError, isValidationError, errorMessage, event streams and uploadsGenerated client
Prefetch on hoverLoad a page's data, or one call, while the pointer rests on a linkGenerated client
Error codesNamed errors from one Kotlin enum instead of status numbersKtor plugin, Generated client
Query parameters as a classcall.query<T>() reads the query string into a class, and the client gets its typeKtor plugin
Changing some fieldsPatch<T> for PATCH routes that tell "not sent" from "set to null"Ktor plugin, Generated client
Two people, one recordA version check that refuses a save over someone else's changeKtor plugin, Generated client
Path parameterscall.pathParameter<T>(name) reads a path parameter as a number, UUID or enumKtor plugin
Paged listsPage<T> and getPage on the server, pages() in the browserKtor plugin, Generated client
Only some fields?fields=id,title sends only those fields, and the client's return type narrows to themKtor plugin, Generated client
Included relations?include=author adds related objects, typed so the field exists only when asked forKtor plugin, Generated client
UploadsFormData bodies with upload progress, and size and type rules shared by both sidesKtor plugin, Generated client
Live updatesServer-sent events become async generators in the clientKtor plugin, Generated client
In load functionsapiWith(event) runs every call through SvelteKit's fetchGenerated client
Refresh the page after a writeonWrite reruns the page's load functions after a successful writeGenerated client
Ask before a callconfirmed asks first and only calls on yesGenerated client
Show errors automaticallyEvery failed call shows a toast, with no error handling in componentsGradle, Generated client
Toasts from the servercall.toast(...) in a route shows a message in the browserKtor plugin
Navigation from the servercall.navigateTo(...) tells the browser which page to open nextKtor plugin
Reload after a deployThe client notices a new build and can offer a reloadKtor plugin, Generated client
Request IDsEvery call carries an X-Request-Id that reaches your logs and the errorKtor plugin, Generated client
TimeoutsOne timeout for every call, or one per callGenerated client
RetriesGET requests that failed on the network are tried againGenerated client
Rate limitsisRateLimitError and retryAfter, and with retries on, one automatic wait and retryGenerated client
Writes that are safe to send twiceIdempotency keys, so a repeated write is answered onceKtor plugin, Generated client
The visitor's time zonecall.timeZone in every route, sent by the clientKtor plugin, Generated client
Search as you typelatest aborts the previous call, so an old answer never winsGenerated client
Fixtures for frontend testsRecord real answers in the dev panel and replay them without a backendGenerated client

Validation and forms ​

FeatureWhat it doesWhere it lives
Validation@JsonSchema bounds and Validated rules, checked on every receive, with field errors in a 422 and the same bounds in the browserKtor plugin, Generated client
Cleaning up input@Trim, @Lowercase and @EmptyAsNull, declared on the fieldKtor plugin
Sensitive fieldsMark a password or token once, and the dev tools show ***Ktor plugin
Form stateformState holds the values, changes, submit state and errors of a formGenerated client
Checks only the server can make"Is this email taken?" while the visitor typesKtor plugin, Generated client

Config and transport ​

FeatureWhat it doesWhere it lives
Runtime configpublicConfig passes values to the frontend at startup, inlined into every pageKtor plugin, Generated client
Changing values without a restartPass a function, and development picks up edits on the next page loadKtor plugin
Environment variablesenvironment declares every variable in one place, with types and a .env.exampleKtor plugin, Gradle
Secrets in the frontend buildsvelteVerifyLeaks fails the build when a secret reached the built filesGradle
Transportjson(), xml(), other formats and compression() in one blockKtor plugin
API compressionAPI responses compressed by default, with zstd when you add itKtor plugin

Frontend ​

Pages, links, styling and components, turned on in Gradle and typed on both sides. Frontend libraries is the overview of every library.

FeatureWhat it doesWhere it lives
Typed routesEvery page as a typed constant: routes in Svelte, FrontendRoutes in KotlinGradle, Generated client
Marking the open pageisActive for menus, without comparing pathsGenerated client
Menu, titles and breadcrumbsEach page says its own title and icon in +page.tsGradle, Generated client
Link previewsTags for chat and social previews, from the same page metadataGradle, Generated client
A new pagesvelteAdd --page writes a page with a typed loadGradle
Pages for a classsvelteAdd --crud writes list, detail and form pages from the generated clientGradle
Renaming a pagesvelteRename moves a page and fixes every typed call to itGradle
Links that are still stringssvelteVerifyRoutes finds string links and suggests the typed callGradle
Links that lead nowheresvelteVerifyLinks finds links to pages that do not existGradle

Look and feel ​

FeatureWhat it doesWhere it lives
TailwindTailwind 4 in Vite and the CSS, with the typography and forms pluginsGradle
DaisyUI themesComponents and themes, typed in TypeScript and Kotlin, with no flash of the wrong themeGradle, Generated client
shadcn themesThe shadcn/ui look for every DaisyUI componentGradle
Custom themesYour own colors, and a dev panel editor to tune them liveGradle
FontsA font served from your own app, preloadedGradle
Lucide iconsA typed LucideIcon enum and an <Icon> component, with only the icons you useGradle, Generated client
Images<enhanced:img> with AVIF and WebP in several widthsGradle
ChartsLayerChart in your theme colors, with typed seriesGradle, Generated client
Installable appA web manifest, icons, a service worker and an offline pageGradle, Ktor plugin
EmailsSvelte components rendered to HTML and text emails at build time, with a typed Kotlin function per emailGradle

Languages ​

FeatureWhat it doesWhere it lives
i18nTyped messages from one JSON file per language, in Svelte and in KotlinGradle, Generated client
StrategiesThe language from a cookie or from a URL prefixGradle
Plurals"1 note" and "2 notes" as one messageGradle, Generated client
Numbers, money and datesFormats that read the same in the browser and on the serverGradle, Generated client
Relative time"3 minutes ago", in the visitor's languageGenerated client
Messages nobody translated yetThe dev panel marks copied, untranslated textsGradle
Messages nothing usessvelteVerifyMessages lists keys you can deleteGradle

Components ​

FeatureWhat it doesWhere it lives
ComponentsSvelte components over the generated helpers, imported as #components/...Gradle, Generated client
FieldLabel, input, hint and validation errors in oneGenerated client
DateInput and DateTimeInputInputs that bind to IsoDate and IsoDateTimeGenerated client
EnumSelectA <select> over a generated enumGenerated client
DataTableA table over any paged route, with loading, empty and error statesGenerated client
FileDropA drop area with previews, progress and refusal reasonsGenerated client
ErrorPageThe page SvelteKit shows when a page cannot loadGenerated client
ThemeToggle and LocaleSwitchTheme and language switches that know your configurationGenerated client
TimeAgoA relative time that keeps itself currentGenerated client
NavigationProgressA thin bar while SvelteKit navigatesGenerated client
Modalsmodal() opens a <dialog> and tells you how it closedGenerated client
ToastsA toast() helper and an optional reload promptGradle, Generated client

Users and security ​

Sign in, permissions and the protections that are on by default.

FeatureWhat it doesWhere it lives
AuthPut the frontend behind Ktor's authentication, with public paths you listKtor plugin
The current userDeclare once how the server finds the user, and get a typed currentUser storeKtor plugin, Generated client
The user in routescall.user in every route, typedKtor plugin
When the session endsA warning before the session ends, with an optional way to extend itKtor plugin, Generated client
PermissionsOne enum and one function, checked on the server and shown in the browserKtor plugin, Generated client
Page guardsWhich pages need a user or a permission, declared once by pageKtor plugin
User preferencesTheme, language and other choices that follow a person to every deviceKtor plugin, Generated client
The login pageEvery "please sign in" ends at your login page, and returns where it startedKtor plugin, Generated client
SessionsSign in with a session cookie, as a recipeRecipe
Typed cookiesCookies as typed values on both sidesKtor plugin, Generated client
Cookie consentA consent helper for cookies that need oneKtor plugin, Generated client
Admin areaPages and routes only admins may use, as a recipeRecipe
Security headersnosniff, frame and referrer headers, and a strict Content-Security-Policy from build hashesKtor plugin
API request guardsOrigin check, body size limit, JSON depth, rate limit and hidden error detailsKtor plugin
Malformed requestsBroken paths and hosts answer 400, without noise in your logKtor plugin
Who may see internal endpointsOpen the status endpoint and API docs to the callers you nameKtor plugin
Verifying a releaseSigned build provenance and an SBOM for every releaseRelease

Develop ​

The dev loop, the dev panel and the tools around them.

FeatureWhat it doesWhere it lives
Setup scriptOne command creates a project with everything wired upScript
ConfiguratorTick options and copy the settingsThis site
Dev workflowsvelteDevAll runs Vite, the compiler and your app with hot reload on one port, in one readable logGradle
Dev panelEvery API call with replay, curl, payload size, SQL counts and duplicates, plus status, slowest routes, environment, migrations, memory and threads, caught emails, cookies, clear site data, routes, public config, accessibility and a theme editorKtor plugin
Server error overlayA failed call shows the exception and a link to your code in the browserKtor plugin
Browser logs in your consoleconsole.log and browser errors land in the dev logKtor plugin
Restart summary and startup timingWhat caused a restart, how long it took, and where startup time wentGradle, Ktor plugin
Multiple frontendsA public site and an admin area as two SvelteKit projects under their own path prefixes, in one app and one JARKtor plugin, Gradle
HTTPS in developmentDevelop with Secure cookies and service workersGradle
When a port is still in useLeftover processes from a crash are cleaned upGradle
DebuggingRun configurations to debug Kotlin and the frontend, in one clickGradle
Live templatesksget, ksapi and more for IntelliJ and WebStormGradle
Checks and toolingEvery verify task, what it catches and when it runsGradle
Naming rulessvelteVerifyNaming checks pages, API routes, DTOs and message keys against the rules you setGradle
svelteDoctorChecks the setup and fixes what it can with --fixGradle
svelteConfigEvery setting on both sides, scored with suggestionsGradle
Format both sidesformat and formatCheck for Kotlin and the frontendGradle
Git pre-commit hookStops unformatted or stale files before a commit, and merges generated filesGradle
Lint rulesESLint rules for mistakes that are easy to make in a ktor-svelte app, shown while you typeGradle, Generated client
Guide for coding assistantsAn AGENTS.md that tells assistants how the project worksGradle
Short task namesdev, sync, doctor and genGradle
Pin BunSet bunVersion, and the plugin downloads that exact Bun, so a fresh machine builds tooGradle

Test ​

FeatureWhat it doesWhere it lives
Browser testsKotlin tests that drive Chromium, Firefox or WebKit against the packaged appTest kit, Gradle
Record a testClick through the app once and get the test written downGradle
The API with your own classesCall the API from a test with your Kotlin classesTest kit
AccessibilitysvelteVerifyA11y runs axe on every prerendered page, light and darkGradle
Smoke testsvelteSmokeTest starts the packaged app in production mode and checks every pageGradle
Fixtures for frontend testsFrontend tests that answer from recorded callsGenerated client

Ship and run ​

FeatureWhat it doesWhere it lives
Build the JARjar, Shadow or buildFatJar, each with the frontend insideGradle
DockerA multi-stage build that runs as a non-root userScript
RailwaysvelteDeploy writes Railway's config from what the project knowsGradle
A plain serverA systemd unit for the JARDocs
Behind a reverse proxynginx, Caddy or a load balancer in front to terminate TLSDocs
Caching and precompressed filesImmutable caching, ETags, zstd, Brotli and gzip, real 404s for stale chunksKtor plugin, Gradle
Built-in endpointsSitemap, robots.txt, a default favicon, status, health and Swagger UIKtor plugin
Health endpoint/_ktor-svelte/health for load balancers, with your own checksKtor plugin
MonitoringWhat to watch in production, in one placeKtor plugin
Request logOne line per request in productionKtor plugin
Errors from the browserFrontend errors reach your server logKtor plugin, Generated client
Page timingsWeb vitals from real browsers, also as metricsKtor plugin, Generated client
Refused requestsCounters for every request the guards refusedKtor plugin
Build infoVersion and commit on both sides, without setupGradle, Ktor plugin
ChecklistWhat to check before the first deployDocs

Still missing something? ​

Documentation for ktor-svelte 1.4.0. Released under the Apache 2.0 license.