

Using Kotlin as a wrapper for third-party libraries or frameworks

You can use Kotlin to interact with server-side JavaScript such as node.js You can use Kotlin to create graphical elements on a web page using WebGL.Ĭreating Kotlin code that targets server-side JavaScript Kotlin provides a series of statically typed interfaces to interact with the Document Object Model, allowing creation and update of DOM elements. You may want to compile Kotlin to JavaScript in the following scenarios:Ĭreating Kotlin code that targets client-side JavaScript Provide the same functionality in the standard library whether targeting JavaScript or the JVM (to the largest possible degree).Provide interoperability with existing module systems.Provide output that is readable JavaScript.

The Kotlin compiler tries to comply with the following goals: Any file that is not Kotlin will be ignored during compilation. However, this excludes the JDK and any JVM or Java framework or library used. When you choose the JavaScript target, any Kotlin code that is part of the project as well as the standard library that ships with Kotlin is transpiled to JavaScript. The current implementation targets ECMAScript 5.1 but there are plans to eventually It does so by transpiling Kotlin to JavaScript. Kotlin provides the ability to target JavaScript. A look at how Kotlin compiles to JavaScript and the use cases for that.
