Hywel Bennett
05/26/2026, 8:03 AM@JsExport on a client class which wraps ktor client, but it seems the ktor-client-core library has a dependency on ws, which is a node dependency, so fails to resolve in the browser.
This seems like an excellent use case for Ktor in multiplatform projects, so I assume I’m just not configuring something correctly. Should this work?hfhbd
05/26/2026, 9:00 AMHywel Bennett
05/26/2026, 7:22 PMCarts below.
@JsExport
class ApiClient(
) {
private val httpClient =
HttpClient(Js) {
install(Resources)
install(ContentNegotiation) {
json()
}
...
}
suspend fun listCarts(): List<Cart> = httpClient.get(Carts()).body()
suspend fun getCart(id: CartId) = httpClient.get(Carts.Id(id)).body<Cart>()
}
Then my React components/hooks can use the @JsExport-ed API types (e.g. Cart above) to interact with my Kotlin wrapper cleanlyhfhbd
05/26/2026, 7:29 PM