You can easily debug KVision applications in most modern browsers (e.g. Chrome or Firefox), which support source maps generated by Kotlin/JS compiler. Source maps allow you to see Kotlin source code in the browser "Sources" panel. You can see line numbers, step through your code, set breakpoints and watch variable values just like with plain JavaScript.

You can also debug KVision application directly in IntelliJ IDEA Ultimate by creating new "JavaScript Debug" configuration pointing to http://localhost:3000 url.

Note: Source maps are disabled by default in all KVision template projects, because the development cycle (hot reload) is a lot faster without them. To enable source maps you need to remove line sourceMaps = false from your build.gradle.kts file and remove line config.devtool = 'eval-cheap-source-map' from webpack.config.d/webpack.js file.


Some UI interactions may be tricky to handle with a debugger, and so being able to fall back to console logging is useful. We find it useful to create a debug function, which is turned on and off with a global boolean.

const val DEBUG = true  // in your App class


    fun debug(s: String, color: LogType? = null) {
        if (DEBUG) {
            console.log("%c $s", when (color) {
                null -> ""
                LogType.EVENT -> "background: #FF0; color: #000000"
                LogType.ROUTING -> "background: #09F; color: #000000"
                LogType. ... -> "background: #E1FDD2; color: #000000"
    enum class LogType {

   debug("user hovered element $element", LogType.Event)

Last updated