Skip to main content
The Compose Hot Reload Runtime API provides programmatic access to hot reload functionality, allowing you to react to reload events and check hot reload status at runtime.

Package

All runtime APIs are in the org.jetbrains.compose.reload package.

Installation

Add the runtime API dependency to your project:
dependencies {
    implementation("org.jetbrains.compose.hot-reload:hot-reload-runtime-api:VERSION")
}
Replace VERSION with the current version of Compose Hot Reload.

When to Use

The Runtime API is useful when you need to:
  • Detect hot reload status: Check if your application is running with hot reload enabled using isHotReloadActive
  • React to reload events: Execute code after each hot reload using AfterHotReloadEffect or invokeAfterHotReload()
  • Manage state: Reinitialize or update state that doesn’t automatically migrate after a reload
  • Integrate with external systems: Notify external tools or services when a reload occurs
  • Debug reload behavior: Add logging or diagnostics around reload events

Available APIs

The Runtime API provides three main categories of functionality:

Properties

isHotReloadActive

Check if the application is running with hot reload enabled

Composable Functions

AfterHotReloadEffect

Composable effect that runs after each hot reload

DevelopmentEntryPoint

Legacy entry point wrapper (deprecated)

Scope Objects

HotReloadScope

Scope for registering reload hooks outside of composable context

Platform Support

The Runtime API is multiplatform and supports:
  • JVM (Desktop)
  • Android
  • macOS (ARM64, x64)
  • Linux (x64, ARM64)
  • iOS (Simulator ARM64, ARM64, x64)
  • WebAssembly (WASM JS)
  • JavaScript
On platforms where hot reload is not available, all APIs safely no-op. The isHotReloadActive property returns false, and registered hooks are never invoked.

Usage Patterns

Basic Hot Reload Detection

import org.jetbrains.compose.reload.isHotReloadActive

fun main() {
    if (isHotReloadActive) {
        println("Running with hot reload enabled")
    }
}

Composable Effect Pattern

import androidx.compose.runtime.Composable
import org.jetbrains.compose.reload.AfterHotReloadEffect
import org.jetbrains.compose.reload.DelicateHotReloadApi

@OptIn(DelicateHotReloadApi::class)
@Composable
fun MyComponent() {
    AfterHotReloadEffect {
        println("Component reloaded")
        // Reinitialize state, refresh data, etc.
    }
}

Non-Composable Hook Pattern

import org.jetbrains.compose.reload.DelicateHotReloadApi
import org.jetbrains.compose.reload.staticHotReloadScope

@OptIn(DelicateHotReloadApi::class)
class MyService : AutoCloseable {
    private val reloadHook = staticHotReloadScope.invokeAfterHotReload {
        println("Service notified of reload")
        // Handle reload
    }
    
    override fun close() {
        reloadHook.close()
    }
}

API Stability

Most Runtime APIs are marked with @DelicateHotReloadApi, indicating they should be used with caution:
These APIs are designed for development-time use. Avoid relying on hot reload behavior in production code. Always check isHotReloadActive before using reload-specific functionality.

Next Steps

HotReloadScope

Learn about registering reload hooks

Composable APIs

Explore composable functions and properties

Build docs developers (and LLMs) love