Skip to content

Instantly share code, notes, and snippets.

@hieuwu
Created August 1, 2023 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hieuwu/987f40dbdaa5a748bc964ee22d00ac19 to your computer and use it in GitHub Desktop.
Save hieuwu/987f40dbdaa5a748bc964ee22d00ac19 to your computer and use it in GitHub Desktop.
SupabaseModule.kt
@InstallIn(SingletonComponent::class)
@Module
object SupabaseModule {
@Provides
@Singleton
fun provideSupabaseClient(): SupabaseClient {
return createSupabaseClient(
supabaseUrl = BuildConfig.SUPABASE_URL,
supabaseKey = BuildConfig.SUPABASE_ANON_KEY
) {
install(Postgrest)
install(GoTrue) {
flowType = FlowType.PKCE
scheme = "app"
host = "supabase.com"
}
install(Storage)
}
}
@Provides
@Singleton
fun provideSupabaseDatabase(client: SupabaseClient): Postgrest {
return client.postgrest
}
@Provides
@Singleton
fun provideSupabaseGoTrue(client: SupabaseClient): GoTrue {
return client.gotrue
}
@Provides
@Singleton
fun provideSupabaseStorage(client: SupabaseClient): Storage {
return client.storage
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment