
Enables checking network connectivity status with a Compose-first API, offering real-time updates across Android, iOS, JVM/Desktop, and Web platforms. Lightweight and dependency-free.
ConnectivityKMP is a Kotlin Multiplatform library that provides a unified way to check network connectivity status across platforms with a Compose-first API.
It supports:
ConnectivityManager callbacks to detect real-time connectivity changes.nw_path_monitor for monitoring connectivity.navigator.onLine).rememberNetworkStatus() you can use anywhere in Compose.Add the dependency from Maven Central:
kotlin {
sourceSets {
commonMain.dependencies {
implementation("io.github.khubaibkhan4:connectivity-kmp:0.0.2")
}
}
}@Composable
fun App() {
// get the Network Status
val isNetworkAvailable by rememberNetworkStatus()
// Network Status
// NetworkStatus.Available, NetworkStatus.NoInternet, NetworkStatus.Lost, NetworkStatus.Unavailable, NetworkStatus.Slow
Box(
modifier = Modifier.fillMaxSize().background(Color.White),
contentAlignment = Alignment.Center
) {
if (isNetworkAvailable == NetworkStatus.Available){
BasicText("Connected")
} else {
BasicText("Disconnected")
}
}
}https://github.com/user-attachments/assets/a5a2251a-6ebe-422d-a928-4c216bb01269
https://github.com/user-attachments/assets/5aa984cf-93bf-4a86-b362-f511f3c19a04
./gradlew :sample:composeApp:run
open project in Android Studio and run the sample app
open 'sample/iosApp/iosApp.xcodeproj' in Xcode and run the sample app
./gradlew :sample:composeApp:wasmJsBrowserRun
./gradlew :shared:publishToMavenLocal
~/.m2/repository/my/connectivity/kmp/
./shared/build.gradle.kts
gpg --full-gen-key
gpg --keyserver keyserver.ubuntu.com --send-keys XXXXXXXX
gpg --export-secret-key XXXXXXXX > XXXXXXXX.gpg
gradle.properties:
signing.keyId=XXXXXXXX
signing.password=[key password]
signing.secretKeyRingFile=../XXXXXXXX.gpg
mavenCentralUsername=[generated username]
mavenCentralPassword=[generated password]
./gradlew :shared:publishAndReleaseToMavenCentral --no-configuration-cache
ConnectivityKMP is a Kotlin Multiplatform library that provides a unified way to check network connectivity status across platforms with a Compose-first API.
It supports:
ConnectivityManager callbacks to detect real-time connectivity changes.nw_path_monitor for monitoring connectivity.navigator.onLine).rememberNetworkStatus() you can use anywhere in Compose.Add the dependency from Maven Central:
kotlin {
sourceSets {
commonMain.dependencies {
implementation("io.github.khubaibkhan4:connectivity-kmp:0.0.2")
}
}
}@Composable
fun App() {
// get the Network Status
val isNetworkAvailable by rememberNetworkStatus()
// Network Status
// NetworkStatus.Available, NetworkStatus.NoInternet, NetworkStatus.Lost, NetworkStatus.Unavailable, NetworkStatus.Slow
Box(
modifier = Modifier.fillMaxSize().background(Color.White),
contentAlignment = Alignment.Center
) {
if (isNetworkAvailable == NetworkStatus.Available){
BasicText("Connected")
} else {
BasicText("Disconnected")
}
}
}https://github.com/user-attachments/assets/a5a2251a-6ebe-422d-a928-4c216bb01269
https://github.com/user-attachments/assets/5aa984cf-93bf-4a86-b362-f511f3c19a04
./gradlew :sample:composeApp:run
open project in Android Studio and run the sample app
open 'sample/iosApp/iosApp.xcodeproj' in Xcode and run the sample app
./gradlew :sample:composeApp:wasmJsBrowserRun
./gradlew :shared:publishToMavenLocal
~/.m2/repository/my/connectivity/kmp/
./shared/build.gradle.kts
gpg --full-gen-key
gpg --keyserver keyserver.ubuntu.com --send-keys XXXXXXXX
gpg --export-secret-key XXXXXXXX > XXXXXXXX.gpg
gradle.properties:
signing.keyId=XXXXXXXX
signing.password=[key password]
signing.secretKeyRingFile=../XXXXXXXX.gpg
mavenCentralUsername=[generated username]
mavenCentralPassword=[generated password]
./gradlew :shared:publishAndReleaseToMavenCentral --no-configuration-cache