Skip to main content

Intoduction and Setup

Introduction​

The 'Migrating to the Kotlin API section' of the Litho docs is aimed at Developers already familiar with the general Java Spec API and Litho concepts. Within its pages, comparisons are made between the use of the Java Spec API and the Kotlin API.

Before continuing, consider the following options:

  • If you aren't familiar with Litho, start with the Tutorial pages then return here later.
  • If you're new to the Litho Kotlin API, start with KComponent and Props.
  • If you just want a reference comparing features in the Spec API to their equivalents in Kotlin, then you'll find the Cheatsheet useful.

Setup - Adding Dependencies​

To use the Kotlin Litho API, you'll need to add the following dependencies into your BUCK file:

BUCK
deps = [
"//fbandroid/libraries/components:litho_core_kotlin",
"//fbandroid/libraries/components/litho-widget-kotlin/src/main/kotlin/com/facebook/litho/kotlin/widget:widget", # for widgets
],
note

If you're getting an unresolved supertypes: com.facebook.litho.KComponent or incompatible types: com.facebook.<Your new KComponent> cannot be converted to com.facebook.litho.Component error, be sure to also add the litho_core_kotlin dependency in the BUCK file for the module that is using the Kotlin component.