Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions topics/whats-new-340.md
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,38 @@ val client = HttpClient {

This allows you to explicitly override earlier default request configuration when composing or reusing client setups.

### Shared source set support for `js` and `wasmJs` targets

Ktor now supports [Kotlin’s shared `web` source set](https://kotlinlang.org/docs/whatsnew2220.html#shared-source-set-for-js-and-wasmjs-targets)
in multiplatform projects, allowing you to share Ktor dependencies between `js` and `wasmJs` targets. This makes it
easier to share web-specific client code, such as HTTP clients and engines, across JavaScript and Wasm/JS.

In your
<path>build.gradle.kts</path>
file, you can declare Ktor dependencies in `webMain`:

```kotlin
kotlin {
sourceSets {
webMain.dependencies {
implementation("io.ktor:ktor-client-js:%ktor_version%")
}
}
}
```

You can then use APIs available to both `js` and `wasmJs` targets:

```kotlin
// src/webMain/kotlin/Main.kt

actual fun createClient(): HttpClient = HttpClient(Js)
```

> Existing <path>.jsAndWasmShared.kt</path> source files continue to work without changes.
>
{style="note"}

## I/O

### Stream bytes from a `ByteReadChannel` to a `RawSink`
Expand Down