Skip to main content

Introduction and Setup

Introduction​

The 'Migrating to the Kotlin API' section of Litho docs is aimed at developers already familiar with the old Spec API and Litho concepts. Within its pages comparisons are made between the use of the 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 the Kotlin API, then you'll find the Cheatsheet useful.

Setup - Adding Dependencies​

Litho is published to Maven Central. Add the dependencies to your module's build.gradle:

dependencies {
implementation 'com.facebook.litho:litho-core:0.50.2'
implementation 'com.facebook.litho:litho-widget-kotlin:0.50.2'
}

From Litho 0.51.0, Kotlin code that calls Litho hooks also has to be built with the Litho Gradle plugin. Apply it with the same version as the Litho dependencies, and add mavenCentral() to pluginManagement.repositories in settings.gradle:

plugins {
id 'com.facebook.litho' version '<Litho version>'
}