KInAppBrowser
🌐 A lightweight in-app browser library for Kotlin Multiplatform.
✨ Features
- 🌐 Native In-App Browsing: Chrome Custom Tabs for Android, SFSafariViewController for iOS
- 📱 Kotlin Multiplatform: Single API for both Android and iOS
- 🎯 : Just one method call to open URLs
🚀 Installation
Add the dependency to your build.gradle.kts of module:
commonMain.dependencies {
implementation("dev.yjyoon:kinappbrowser:1.0.0")
}
📖 Usage
Android
Initialize KInAppBrowser in your Activity and open URLs:
import dev.yjyoon.kinappbrowser.KInAppBrowser
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
KInAppBrowser.init()
KInAppBrowser.()
}
}
iOS
No initialization needed - directly open URLs:
import dev.yjyoon.kinappbrowser.KInAppBrowser
KInAppBrowser.open("https://github.com/yjyoon-dev/KInAppBrowser")
KInAppBrowser.close()
Compose Multiplatform
Works seamlessly with Compose Multiplatform:
@Composable
fun MyScreen() {
Button(
onClick = {
KInAppBrowser.open("https://example.com")
}
) {
Text("Open Website")
}
}
🔧 Platform Details
Android Implementation
- Uses Chrome Custom Tabs for optimal performance and user experience
- Automatic fallback to default browser if Custom Tabs unavailable
- Shared cookies and authentication with Chrome
- Fast loading with pre-warming capabilities
- Requires Activity context initialization
iOS Implementation
- Uses SFSafariViewController for full Safari browsing experience
- Shared cookies and website data with Safari
- Built-in security features and privacy protection
- Support for Safari features like Reader mode and AutoFill
- Automatic handling of different URL schemes like Universal links
📋 Requirements
- Android: API level 24+ (Android 7.0)
- iOS: iOS 14.0+
🛠️ API Reference
Common API
expect object KInAppBrowser {
fun open(url: String)
}
Android-Specific API
fun init(activity: Activity)
iOS-Specific API
fun close()
📱 Sample App
Check out the sample app for a complete working example with Compose Multiplatform.
📄 License
Copyright 2025 yjyoon
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http:
Unless applicable law agreed to writing, software
distributed under the License distributed an BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express implied.
See the License the specific language governing permissions
limitations under the License.
🔗 Links