gitmyhub

coil

Kotlin ★ 12k updated 21h ago

Image loading for Android and Compose Multiplatform.

Coil is a Kotlin image loading library for Android and Compose Multiplatform apps that fetches and displays remote images efficiently, with automatic memory caching, disk caching, scaling, and request cancellation built in.

KotlinCoroutinesOkioOkHttpJetpack ComposeAndroidsetup: easycomplexity 2/5

Coil is an image loading library for Android apps and apps built with Compose Multiplatform, which is a toolkit for building apps that run on multiple platforms from shared Kotlin code. Its job is to fetch images from a URL and display them in your app efficiently, handling the complex parts of that process so you do not have to.

The name is an acronym for Coroutine Image Loader. Coroutines are a Kotlin feature for handling background work, like downloading a file, without freezing the app's interface. Coil uses coroutines internally to load images without blocking the main thread. The README describes it as fast, lightweight, easy to use, and modern.

In terms of performance, Coil caches images in memory and on disk, scales images down to the size they actually need to be shown at rather than loading full-resolution files, and automatically pauses or cancels image requests when they are no longer needed, for example when a user scrolls past a list item. These behaviors happen by default without you needing to configure them.

The API is designed to stay out of your way. When using Compose, loading an image from a URL takes a single composable called AsyncImage, which you pass the image URL and a description. That is the entire integration for a basic setup. Additional configuration is available for caching policies, transformations, placeholder images, and error states.

Coil depends only on Kotlin, Coroutines, and Okio (a small I/O library), plus an optional networking library like OkHttp or Ktor. It is licensed under the Apache 2.0 license and the full documentation is available on the project's website.

Where it fits