Skip to main content
Version: 4.2

Welcome to Koin

The Pragmatic Kotlin Dependency Injection Framework - Simple AND Powerful

Koin is a lightweight dependency injection framework for Kotlin developers. Whether you're building Android apps, Kotlin Multiplatform projects, backend services with Ktor, or any Kotlin application, Koin makes dependency injection straightforward and intuitive.

Why Koin?

Koin was designed with a clear philosophy: you shouldn't have to choose between simplicity and capability. With Koin, you get both.

DSL & Annotations - Choose What You Want

Koin is powerful with both approaches. Prefer a clean Kotlin DSL? Use it. Like annotations? Use them. Both are first-class citizens, equally powerful.

ValueWhat it means
ProductiveEasy to learn, easy to write. Get DI working in minutes, not hours
Developer-FriendlyDSL or Annotations - your choice. Clear errors, easy debugging, best DX
ScalablePowers large enterprise applications with complex dependency graphs
SafeCompile-time safety with Koin Compiler Plugin
DynamicRuntime flexibility: load modules dynamically, lazy loading, feature flags

Where to Start?

Choose your path based on your experience level:

New to Dependency Injection?

Start with the fundamentals:

Know DI, New to Koin?

Jump right into Koin:

Coming from Hilt/Dagger?

See how Koin compares:

Ready to Code?

Koin's Approaches

Koin offers flexibility in how you define your dependencies:

ApproachStatusDescription
Koin Compiler Plugin (Kotlin 2.x)RecommendedDSL: single<MyService>(), factory<MyRepo>(), viewModel<MyVM>().
Koin Compiler Plugin (Kotlin 2.x)RecommendedAnnotations: @Singleton, @Factory, @KoinViewModel. Auto-detects dependencies, compile-time safety.
Classic DSLFully SupportedsingleOf(::MyService), single { MyService(get()) }. Works with any Kotlin version. Compiler Plugin adds safety on top when you're ready.
KSP AnnotationsDeprecatedMigrate to Compiler Plugin - same annotations, better processing.

Learn more in What is Koin? and Koin Compiler Plugin.

Platform Support

Koin works everywhere Kotlin runs:

PlatformPackageStatus
Kotlin/JVMkoin-core✅ Full support
Androidkoin-android✅ Full support
Compose (Multiplatform)koin-compose✅ Full support
iOSkoin-core✅ Full support
Desktopkoin-core✅ Full support
Web (JS/Wasm)koin-core✅ Full support
Ktorkoin-ktor✅ Full support

Quick Example

Here's a taste of what Koin looks like:

// Define your classes
class UserRepository(private val api: ApiService)
class UserViewModel(private val repository: UserRepository) : ViewModel()

// Define your module with Compiler Plugin DSL
val appModule = module {
single<ApiService>()
single<UserRepository>()
viewModel<UserViewModel>()
}

// Start Koin
startKoin {
modules(appModule)
}

// Inject in your Activity
class MainActivity : AppCompatActivity() {
private val viewModel: UserViewModel by viewModel()
}

Or with annotations:

@Singleton
class UserRepository(private val api: ApiService)

@KoinViewModel
class UserViewModel(private val repository: UserRepository) : ViewModel()

@Module
@ComponentScan("com.myapp")
class AppModule

Ready to get started? Head to the Setup Guide.