Extends supabase-kt with a Coil integration for image loading.
Supported targets:
Target | Android |
---|---|
Status | ✅ |
For Compose Multiplatform support, checkout the Coil 3 integration
dependencies {
implementation("io.github.jan-tennert.supabase:coil-integration:VERSION")
}
Install plugin in main SupabaseClient. See the documentation for more information
val client = createSupabaseClient(
supabaseUrl = "https://id.supabase.co",
supabaseKey = "apikey"
) {
//...
install(Storage) {
//your config
}
install(CoilIntegration)
}
Create a new ImageLoader with the Supabase Fetcher. See the Coil documentation for more information.
ImageLoader.Builder(context)
.components {
add(supabaseClient.coil)
}
.build()
You can also replace the default Coil Image Loader in your application. See the Coil documentation for more information.
You can easily create an image request like this:
val request = ImageRequest.Builder(context)
.data(authenticatedStorageItem("icons", "profile.png")) //for non-public buckets
.build()
Or if you are using Jetpack Compose:
AsyncImage(
model = publicStorageItem("icons", "profile.png"), //for public buckets
contentDescription = null,
)
The Coil integration will automatically add the Authorization header to the request if the bucket is not public.