Welcome
Koin is a dependency injection framework for Kotlin. You declare how your classes are built in modules, Koin creates and wires the instances at runtime, and the optional Koin Compiler Plugin checks the whole graph when you build. It runs on Android, Compose, Kotlin Multiplatform, Ktor and any Kotlin/JVM application.
This page is a map of the documentation. Each section below says which question it answers and where to start.
class UserRepository(private val api: ApiService)
val appModule = module {
single<ApiService>()
single<UserRepository>()
}
fun main() {
startKoin { modules(appModule) }
}
I want to...
- Understand dependency injection first: What is Dependency Injection?
- Understand how Koin works in five minutes: Core Concepts
- Pick between DSL and annotations: Choosing your style
- Add Koin to my Gradle build: Gradle Setup
- Inject a ViewModel in a Composable: ViewModel in Compose
- Inject in an Activity, Fragment or Service: Android Entry Points
- Wire Retrofit, Room or OkHttp: Android Library Integration
- Share modules between Android and iOS: KMP Sharing Patterns
- Pass a runtime value such as an ID to a definition: Injected Parameters
- Test my Koin configuration: Verifying your Koin configuration and Compile-Time Safety
- Fix a "No definition found" error: Troubleshooting
- Migrate from Hilt: Migrating from Hilt
- Move my annotations from KSP to the Compiler Plugin: Migrating from KSP
- See how Koin behaves in production: Production Monitoring
Where to go
Get Started
What is Koin, how does it work, which style should I use?
- What is Koin?: what Koin is and how it works, runtime and compile time.
- Core Concepts: definitions, modules, the container, injection, scopes.
- Choosing your style: Compiler Plugin DSL, annotations or classic DSL.
- Koin Compiler Plugin: what the plugin does at build time.
Setup
What do I add to my build?
- Setup: what to install for each platform.
- Gradle Setup: the BOM and every Koin artifact.
- Compiler Plugin Setup: install and configure the Gradle plugin.
Tutorials
How do I build a first app with Koin, step by step?
- Kotlin: a plain Kotlin application.
- Android - ViewModel and Android - Jetpack Compose.
- Compose Multiplatform: shared UI on Android and iOS.
- Ktor: a server application.
Core
How do I declare, organize and retrieve dependencies on any platform?
- Starting Koin:
startKoin, logging, properties. - Modules and Definitions: declare what Koin builds.
- Scopes: instances tied to a lifecycle.
- Troubleshooting: errors and how to read them.
Platforms
How do I use Koin with a specific platform or framework?
- Android: Start Koin on Android, Android ViewModel, Multi-Module Android Apps.
- Compose: Koin for Compose, ViewModel in Compose, Navigation 3.
- Kotlin Multiplatform: KMP Setup, Sharing Patterns.
- Ktor: Koin for Ktor, Request Scopes.
Testing
How do I test code that uses Koin, and test the configuration itself?
- Injecting in Tests:
KoinTest, replacing definitions with fakes. - Verifying your Koin configuration: check modules in a unit test.
- Android Instrumented Testing and Testing Composables.
Production & Tooling
Which tools help me write, inspect and run Koin apps?
- Tooling: overview of the tools around Koin.
- IDE Plugin: navigation and checks in Android Studio and IntelliJ IDEA.
- Monitor and Production Monitoring: see what Koin does at runtime.
Migration
I use another framework or an older Koin setup. How do I move?
- Koin vs Hilt: how the two compare.
- Migrating from Hilt: step-by-step guide.
- JSR-330 Compatibility: keep
@Injectand@Singletonfromjavax.inject. - Migrating from KSP: move annotations to the Compiler Plugin.
Reference
What are all the keywords, annotations and options?
- DSL Reference: every DSL keyword.
- Annotations Reference: every annotation and its parameters.
- Compiler Plugin Options: every Gradle option of the plugin.
Support
Which version should I use, what changed, where do I get help?
- Releases: versions, changes and upgrade notes.
- API Stability: what stable, experimental and internal mean.
- Support: roadmap, community and support options.
Related
- What is Koin?: the next page to read if you are new to Koin.
- Core Concepts: the mental model behind every other page.
- Setup: install Koin for your platform.