Integrating Kotlin/JS in a Kotlin Multiplatform library
summary
Kotlin/JS compiles Kotlin to JS via the Gradle plugin with built‑in NPM, yarn and webpack support; use IR compiler and choose browser vs node and binaries:library vs executable. Existing KMM code needs a mobileMain to avoid massive refactors; expect/actual plus JS export annotations expose APIs, but suspended functions don’t export (use Promise conversion) and collections often require arrays. Dukat generates external declarations for NPM modules; watch bundle sizes (examples: kotlinx-datetime ~200 KB, serialization ~300 KB, Ktor ~862 KB, combined 1.3 MB before improvements; 1.7.10 cuts sizes ~40% in tests).
AI-written summary · about
chapters (12)
- 0:00Introduction
- 1:58What is Kotlin JS
- 3:24Setting up Kotlin JS
- 5:31Refactoring for JS compatibility
- 7:59JS build options
- 14:29Exporting Kotlin to JS
- 17:38Challenges and limitations
- 21:46Third-party dependencies
- 26:21Multiplatform libraries
- 28:49Bundle size impact
- 31:19Architecture adjustments
- 32:44Production use and buzz








