Package-level declarations

Functions and other APIs specific to the JavaScript platform.

Functions and other APIs specific to the JavaScript platform.

Functions and other APIs specific to the JavaScript platform.

Types

Link copied to clipboard
external interface Console

Exposes the console API to Kotlin.

Since Kotlin 1.1
Link copied to clipboard
external class Date

Exposes the Date API to Kotlin.

Since Kotlin 1.1
Link copied to clipboard
external interface Dynamic : JsAny

Represents universal type for JS interoperability.

Since Kotlin 1.8
Link copied to clipboard

Forces a top-level property to be initialized eagerly, opposed to lazily on the first access to file and/or property.

Since Kotlin 1.6
Link copied to clipboard

This annotation marks the experimental JS-collections API that allows to manipulate with native JS-collections The API can be removed completely in any further release.

Since Kotlin 2.0
Link copied to clipboard
annotation class ExperimentalJsExport

Marks experimental JS export annotations.

Since Kotlin 1.4
Link copied to clipboard
annotation class ExperimentalJsFileName

Marks experimental JsFileName annotation.

Since Kotlin 1.9
Link copied to clipboard

This annotation marks the experimental Kotlin/JS reflection API that allows to create an instance of provided KClass The API can be removed completely in any further release.

Since Kotlin 1.9
Link copied to clipboard
annotation class ExperimentalJsStatic

Marks the experimental JsStatic annotation.

Since Kotlin 2.0
Link copied to clipboard
external interface JsAny

Any JavaScript value except null or undefined

Since Kotlin 1.8
Link copied to clipboard
external class JsArray<T : JsAny?> : JsAny

JavaScript Array

Since Kotlin 1.8
Link copied to clipboard
external class JsBigInt : JsAny

JavaScript primitive bigint

Since Kotlin 1.8
Link copied to clipboard
external class JsBoolean : JsAny

JavaScript primitive boolean

Since Kotlin 1.8
Link copied to clipboard
external interface JsClass<T : Any>

Represents the constructor of a class. Instances of JsClass can be passed to JavaScript APIs that expect a constructor reference.

Since Kotlin 1.1
Link copied to clipboard

Exception thrown by the JavaScript code. All exceptions thrown by JS code are signalled to Wasm code as JsException. One can catch such exception in Wasm, but no details of the original exception can be retrieved from it.

Since Kotlin 1.8
Link copied to clipboard

Exports top-level declaration on JS platform.

Since Kotlin 1.4

Exports top-level declaration on JS platform.

Since Kotlin 1.3
actual annotation class JsExport

Exports top-level declaration on JS platform.

Since Kotlin 1.8
Link copied to clipboard

When placed on a function parameter, requires the type of the passed argument to be external.

Since Kotlin 1.9
Link copied to clipboard

When placed on an external interface or class, requires all its child interfaces, classes, and objects to be external as well.

Since Kotlin 1.9
Link copied to clipboard
expect annotation class JsFileName(val name: String)

Specifies the name of the compiled file produced from the annotated source file instead of the default one.

Since Kotlin 1.9
@Target(allowedTargets = [AnnotationTarget.FILE])
actual annotation class JsFileName(val name: String)

Specifies the name of the compiled file produced from the annotated source file instead of the default one.

Since Kotlin 1.9
Link copied to clipboard

Denotes an external declaration that must be imported from native JavaScript library.

Since Kotlin 1.1

Denotes an external declaration that must be imported from JavaScript module.

Since Kotlin 1.8
Link copied to clipboard

Gives a declaration (a function, a property or a class) specific name in JavaScript.

Since Kotlin 1.0

Gives a declaration (a function, a property or a class) specific name in JavaScript.

Since Kotlin 1.1

Specifies JavaScript name for external and imported declarations

Since Kotlin 1.8
Link copied to clipboard

Denotes an external declaration that can be used without module system.

Since Kotlin 1.1
Link copied to clipboard
external class JsNumber : JsAny

JavaScript primitive number

Since Kotlin 1.8
Link copied to clipboard
external object JSON

Exposes the JavaScript JSON object to Kotlin.

Since Kotlin 1.1
Link copied to clipboard
external interface Json

An interface for indexing access to a collection of key-value pairs, where type of key is String and type of value is Any?.

Since Kotlin 1.1
Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FILE])
annotation class JsQualifier(val value: String)

Adds prefix to external declarations in a source file.

Since Kotlin 1.1
@Target(allowedTargets = [AnnotationTarget.FILE])
annotation class JsQualifier(val value: String)

Adds prefix to external declarations in a source file.

Since Kotlin 1.8
Link copied to clipboard
sealed external interface JsReference<out T : Any> : JsAny

JavaScript value that can serve as a reference for any Kotlin value.

Since Kotlin 1.8
Link copied to clipboard

Specifies that an additional static method is generated from the annotated companion object member if it's a function. If the member is a property, additional static getter/setter methods are generated.

Since Kotlin 2.0

Specifies that an additional static method is generated from the annotated companion object member if it's a function. If the member is a property, additional static getter/setter methods are generated.

Since Kotlin 2.0
Link copied to clipboard
external class JsString : JsAny

JavaScript primitive string

Since Kotlin 1.8
Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
annotation class nativeGetter
Since Kotlin 1.1
Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
annotation class nativeInvoke
Since Kotlin 1.1
Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
annotation class nativeSetter
Since Kotlin 1.1
Link copied to clipboard
open external class Promise<out T>(executor: (resolve: (T) -> Unit, reject: (Throwable) -> Unit) -> Unit)

Exposes the JavaScript Promise object to Kotlin.

Since Kotlin 1.1
external class Promise<out T : JsAny?>(executor: (resolve: (T) -> Unit, reject: (JsAny) -> Unit) -> Unit) : JsAny

Exposes the JavaScript Promise object to Kotlin.

Since Kotlin 1.8
Link copied to clipboard
external class RegExp(pattern: String, flags: String? = definedExternally)

Exposes the JavaScript RegExp object to Kotlin.

Since Kotlin 1.1
Link copied to clipboard
external interface RegExpMatch

Represents the return value of RegExp.exec.

Since Kotlin 1.1

Properties

Link copied to clipboard
external val console: Console

Exposes the console API to Kotlin.

Since Kotlin 1.1
Link copied to clipboard

The property that can be used as a placeholder for statements and values that are defined in JavaScript.

Since Kotlin 1.1

The property that can be used as a placeholder for statements and values that are defined in JavaScript.

Since Kotlin 1.8
Link copied to clipboard
val <T : Any> KClass<T>.js: JsClass<T>

Obtains a constructor reference for the given KClass.

Since Kotlin 1.1
Link copied to clipboard
val <T : Any> JsClass<T>.kotlin: KClass<T>

Obtains a KClass instance for the given constructor reference.

Since Kotlin 1.1
Link copied to clipboard
external val noImpl: Nothing
Since Kotlin 1.1
Link copied to clipboard
external val undefined: Nothing?

Exposes the JavaScript undefined property to Kotlin.

Since Kotlin 1.1

Functions

Link copied to clipboard
fun Json.add(other: Json): Json

Adds key-value pairs from other to this. Returns the original receiver.

Since Kotlin 1.1
Link copied to clipboard
inline fun RegExpMatch.asArray(): Array<out String?>

Converts the result of RegExp.exec to an array where the first element contains the entire matched text and each subsequent element is the text matched by each capturing parenthesis.

Since Kotlin 1.1
Link copied to clipboard
inline fun Any?.asDynamic(): dynamic

Reinterprets this value as a value of the /docs/reference/dynamic-type.html.

Since Kotlin 1.1

Reinterprets this value as a value of the Dynamic type.

Since Kotlin 1.8
Link copied to clipboard
Since Kotlin 1.1
Link copied to clipboard
external fun eval(expr: String): dynamic

Exposes the JavaScript eval function to Kotlin.

Since Kotlin 1.1
Link copied to clipboard
inline operator fun RegExpMatch.get(index: Int): String?

Returns the entire text matched by RegExp.exec if the index parameter is 0, or the text matched by the capturing parenthesis at the given index.

Since Kotlin 1.1
fun <T : Any> JsReference<T>.get(): T

Retrieve original Kotlin value from JsReference

Since Kotlin 1.8
operator fun <T : JsAny?> JsArray<T>.get(index: Int): T?
Since Kotlin 1.8
Link copied to clipboard
operator fun dynamic.iterator(): Iterator<dynamic>

Allows to iterate this dynamic object in the following cases:

Since Kotlin 1.1
Link copied to clipboard
external fun js(code: String): dynamic

Puts the given piece of a JavaScript code right into the calling function. The compiler replaces call to js(...) code with the string constant provided as a parameter.

Since Kotlin 1.1
external fun js(code: String): Nothing

This function allows you to incorporate JavaScript code into Kotlin/Wasm codebase. It is used to implement top-level functions and initialize top-level properties.

Since Kotlin 1.9
Link copied to clipboard
fun json(vararg pairs: Pair<String, Any?>): Json

Returns a simple JavaScript object (as Json) using provided key-value pairs as names and values of its properties.

Since Kotlin 1.1
Link copied to clipboard
external fun jsTypeOf(a: Any?): String

Function corresponding to JavaScript's typeof operator

Since Kotlin 1.1
Link copied to clipboard
external fun parseFloat(s: String, radix: Int = definedExternally): Double
Since Kotlin 1.1
Link copied to clipboard
external fun parseInt(s: String): Int
external fun parseInt(s: String, radix: Int = definedExternally): Int
Since Kotlin 1.1
Link copied to clipboard

Resets the regular expression so that subsequent RegExp.test and RegExp.exec calls will match starting with the beginning of the input string.

Since Kotlin 1.1
Link copied to clipboard
operator fun <T : JsAny?> JsArray<T>.set(index: Int, value: T)
Since Kotlin 1.8
Link copied to clipboard
inline fun <T, S> Promise<Promise<T>>.then(noinline onFulfilled: (T) -> S?): Promise<S>
inline fun <T, S> Promise<Promise<T>>.then(noinline onFulfilled: (T) -> S?, noinline onRejected: (Throwable) -> S?): Promise<S>
Since Kotlin 1.1
Link copied to clipboard
Since Kotlin 1.8
Link copied to clipboard
Since Kotlin 1.8
Link copied to clipboard
Since Kotlin 1.8
Link copied to clipboard
Since Kotlin 1.8
Link copied to clipboard
Since Kotlin 1.8
Link copied to clipboard
Since Kotlin 1.8
Link copied to clipboard
Since Kotlin 1.8
Link copied to clipboard
Since Kotlin 1.8
Link copied to clipboard
Since Kotlin 1.8
Link copied to clipboard

For a Dynamic value caught in JS, returns the corresponding Throwable if it was thrown from Kotlin, or null otherwise.

Since Kotlin 1.8
Link copied to clipboard
inline fun <T> dynamic.unsafeCast(): T

Reinterprets this dynamic value as a value of the specified type T without any actual type checking.

Since Kotlin 1.1
inline fun <T> Any?.unsafeCast(): T

Reinterprets this value as a value of the specified type T without any actual type checking.

Since Kotlin 1.1
fun <T : JsAny> JsAny.unsafeCast(): T

Cast JsAny to other Js type without runtime check

Since Kotlin 1.8