Open URL with Compose Multiplatform

Opening a URL within a Composable function is a common task, and with Compose Multiplatform, it's easy to implement across Android, iOS, Desktop, and Web. Here's a quick guide on how to achieve this.

Compose Multiplatform allows us to share UI code across different platforms. To open a URL, we just need to get LocalUriHandler and call openUri

val uriHandler = LocalUriHandler.current
uriHandler.openUri("https://kotlinlang.org/docs/multiplatform.html")

With Compose Multiplatform, opening a URL from a Composable function is straightforward. This approach keeps your code clean and maintainable while leveraging the power of Compose Multiplatform.

Get more tips to ship faster with compose multiplatform on appkickstarter.com.