For AI agents: the documentation index is at llms.txt. Guide pages have a markdown version at the same path with .md appended, before any query string or fragment.
Independently of which Supabase module you are using, you will need to initialize the main client first and install the module.
To create a new client, you can use the createSupabaseClient function.
When installing a module, you can pass a block to configure it.
supabase-kt provides several platform implementations for OAuth and OTP link verification.
On JVM, it uses a HTTP Callback Server to receive the session data from a successful OAuth sign-in.
Note: OTP link verification such as sign ups are not supported on JVM. You may have to send a verification token rather than a url in your E-Mail. To send the token, rather than a redirect url, you have to change {{ .ConfirmationURL }} in your sign up email to {{ .Token }}
On Android, IOS & macOS, it uses deeplinks. Refer to the guide below on how to setup deeplinks. Alternatively you could use Native Google Auth or a WebView for OAuth. Refer to our demo to learn more. On JS, it uses the website origin as the callback url. Session importing gets handled automatically. Windows, tvOS, watchOS & Linux currently have no default implementation. Feel free to create a PR.
You always make your own implementation and use gotrue.parseSessionFromFragment(fragment) or gotrue.parseSessionFromUrl(url) to let supabase-kt handle the parsing after receiving a callback. Then you can simply use gotrue.importSession(session).
Deeplinks are supported on Android, IOS and macOS.
host and the scheme in the GoTrue config:
install(GoTrue) {
host = "deeplink host" // this can be anything, eg. your package name or app/company url (not your supabase url)
scheme = "deeplink scheme"
//Android only, you can also change that OAuth/SSO logins open in a custom tab, rather than an external browser:
defaultExternalAuthAction = ExternalAuthAction.CUSTOM_TABS //defaults to EXTERNAL_BROWSER
}
supabase.handleDeeplinks(intent) supabase.handleDeeplinks(url)Then you can just sign in using OAuth:
supabase.gotrue.loginWith(Google)
Or open OTP links directly in your app.
supabase-kt supports the PKCE authentication flow. To use it, you just have to change the flowType in the GoTrue configuration:
install(GoTrue) {
flowType = FlowType.PKCE
}
That's it! If you already implemented deeplinks to handle OTPs and OAuth you don't have to change anything!
val supabase = createSupabaseClient(
supabaseUrl = "https://xyzcompany.supabase.co",
supabaseKey = "publishable-or-anon-key"
) {
install(GoTrue)
install(Postgrest)
//install other modules
}
val supabase = createSupabaseClient(
supabaseUrl = "https://xyzcompany.supabase.co",
supabaseKey = "publishable-or-anon-key"
) {
install(GoTrue) {
alwaysAutoRefresh = false // default: true
autoLoadFromStorage = false // default: true
//and more...
}
}
val supabase = createSupabaseClient(
supabaseUrl = "https://xyzcompany.supabase.co",
supabaseKey = "publishable-or-anon-key"
) {
install(Postgrest) {
defaultSchema = "schema" // default: "public"
propertyConversionMethod = PropertyConversionMethod.SERIAL_NAME // default: PropertyConversionMethod.CAMEL_CASE_TO_SNAKE_CASE
}
}
val supabase = createSupabaseClient(
supabaseUrl = "https://xyzcompany.supabase.co",
supabaseKey = "publishable-or-anon-key"
) {
install(Storage) {
transferTimeout = 90.seconds // Default: 120 seconds
}
}
val supabase = createSupabaseClient(
supabaseUrl = "https://xyzcompany.supabase.co",
supabaseKey = "publishable-or-anon-key"
) {
install(Realtime) {
reconnectDelay = 5.seconds // Default: 7 seconds
}
}
val supabase = createSupabaseClient(
supabaseUrl = "https://xyzcompany.supabase.co",
supabaseKey = "publishable-or-anon-key"
) {
install(Functions) {
//no custom settings
}
}
val supabase = createSupabaseClient(
supabaseUrl = "https://xyzcompany.supabase.co",
supabaseKey = "publishable-or-anon-key"
) {
install(GraphQL) {
apolloConfiguration {
//custom configuration
}
}
}