Docs

Supported types

Kotlin-to-TypeScript mappings, object lifetimes and current compiler limitations.

On this page

How Kotlin maps to JavaScript#

Kotlin JavaScript
Boolean, String, Char boolean, string
Int, Double, Float, Long, unsigned numbers… number (Long and unsigned values lose precision above 2^53)
T? T | null
List, Set, Array, varargs arrays
Map<String, V> Record<string, V>
@ReactNativeType class (data class by default) a plain object, copied across the bridge
@ReactNativeType enum a union of the entry names
@ReactNativeClass class or interface a JS class holding a handle to the Kotlin object; call release() when done
@ReactNativeClass object a constant with its members
suspend fun a function returning a Promise
Lambda parameter a JS callback, called through a TurboModule event
@ReactNativeComponent composable a React component: props from parameters, events from () -> Unit style callbacks

Kotlin objects referenced from JavaScript stay alive in a handle registry until the JavaScript side releases them.

Limitations#

  • Generic declarations, recursive value types and function types outside parameters are rejected.
  • Kotlin default parameter values must be passed from JavaScript, except for Modifier and the slots of components.
  • Callbacks registered from JavaScript are never released.
  • iOS rejects Char in nullable, collection or lambda positions, value classes, extension properties and unsigned varargs, which Kotlin/Native exports as opaque types.
  • Two exported classes with the same name in different packages get the same Objective-C name.
  • An uncaught Kotlin exception in a synchronous iOS call crashes the app. Suspend functions reject their promise.
Check the repository for changes The project is young. The compiler README is the source of truth for the supported types, and these limitations may have moved since this page was written.

See Annotations for what you can export.