The recommended way to create a new application is to use plugin for IntelliJ IDEA. Just install the plugin from JetBrains Marketplace in your IDE and run File -> New -> Project... from the main menu. Choose Kilua group, select desired project type, choose options and optional modules from the list on the first page. On the second page choose your project name and location. Your project will be generated and opened in IDE when you click Finish button. After a few moments required to download all required dependencies you are ready to go.
You can also just copy the and modify it by adding modules.
gradle/libs.versions.toml
The template uses Gradle version catalog. All plugins and dependencies are listed in the gradle/libs.versions.toml file.
The build.gradle.kts file is responsible for the definition of the build process. It declares all required dependencies (in particular Kilua optional modules). Kilua Gradle plugin is used to simplify the configuration.
As Kilua apps can be compiled to both Kotlin/Js and Kotlin/WasmJs targets, the source code for the application is contained in the src/commonMain directory. It consists of Kotlin sources in the kotlin directory and the resources directory with main index.html file and optional assets (e.g. images, CSS files, translation files).
Test sources are contained in the src/commonTest directory.
When creating fullstack or SSR apps with additional JVM target, the common source set can't be used for the fronted code. It is recommended to create a custom, shared webMain source set.
The Application class
The main Kilua application class must extend the dev.kilua.Application class and override thestart method. Use startApplicationfunction to initialize and start your app.
App.kt
class App : Application() {
override fun start() {
root("root") {
div {
+"Hello World!"
}
}
}
}
fun main() {
startApplication(::App)
}