# Hot Module Replacement

Every KVision project utilizes the HMR (Hot Module Replacement) feature of [Webpack](https://webpack.js.org/concepts/hot-module-replacement/). HMR can significantly speed up development by updating browser content automatically after changes are made in the source code. It allows you to retain the state of the application, too. Just override the `start` method with a `state` parameter.

{% code title="App.kt" %}

```kotlin
package com.example

import io.kvision.Application
import io.kvision.module
import io.kvision.panel.root

class App : Application() {

    override fun start(state: Map<String, Any>) {
        root("kvapp") {
            // TODO
        }
    }

    override fun dispose(): Map<String, Any> {
        return mapOf()
    }

}

fun main() {
    startApplication(::App, js("import.meta.webpackHot").unsafeCast<Hot?>())
}
```

{% endcode %}

The HMR module calls the `start` method after every change in the source code, and this method is responsible for recreating the user interface.

In case of a need to retain the state of the application, it should be returned as a `Map<String, Any>` from the`dispose` method. It will be sent back to the application in the `state` parameter of the `start` method.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kvision.gitbook.io/kvision-guide/1.-getting-started-1/hot-module-replacement.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
