Skip to content

Recipes ​

Complete, step-by-step answers to tasks most apps need. Each recipe starts from what you want to build, shows the Kotlin and the Svelte side together, and uses only Ktor, SvelteKit and what ktor-svelte already does, so you can copy it and adapt the names.

Pick a recipe ​

You want to...RecipeLevelTime
Go from a Kotlin class to a table, a detail page and formsCRUD in minutesBeginner10 min
Let people sign in and stay signed inSign in with a session cookieBeginner20 min
Give users roles that decide what they may doA role-based appIntermediate30 min
Add pages and routes that only admins can useAdd an admin areaIntermediate20 min
Accept files with progress and shared size and type rulesUpload filesBeginner15 min
Show long lists one page at a timePage through long listsBeginner15 min
Update results while someone typesSearch as you typeBeginner10 min
Push changes from the server to open pagesStream live updatesIntermediate15 min
Offer the site in several languages, with local dates and pricesA multilingual siteIntermediate30 min

Build an app from them ​

The recipes fit together. A typical team app uses them in this order:

  1. CRUD in minutes for the first resource.
  2. Sign in with a session cookie to put it behind a login.
  3. A role-based app and Add an admin area when not everyone may do everything.
  4. Page through long lists and Search as you type once the lists grow.
  5. Upload files, Stream live updates and A multilingual site as the app needs them.

examples/showcase is such an app: a team board with sign-in, roles, an admin area, uploads, paged tables and two languages. Read its source next to the recipes, or see Examples.

Smaller answers ​

Some tasks are a few lines and live on the feature pages:

You want to...Where
Keep a typed value in a cookieTyped cookies
Ask for consent before setting a cookieCookie consent
Warn before a session endsWhen the session ends
Check one field on the server while someone typesChecks only the server can make
Show a message from a route as a toastToasts from the server
Check health from a load balancerHealth endpoint

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