Escriu per cercar…

Supabase

Introducció

You can use supabase-kt to interact with your Postgres database, listen to database changes, invoke Deno Edge Functions, build login and user management functionality, and manage large files.

To see supported Kotlin targets, check the corresponding module README on [GitHub](https://github.com/supabase-community/supabase-kt.

Project

Supabase Modules

Add one or more modules to your project depending on your needs.

The available modules are:

  • auth-kt
  • realtime-kt
  • storage-kt
  • functions-kt
  • postgrest-kt
  • Other plugins also available here

Check out the different READMEs for information about supported Kotlin targets.

Supabase Client

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.

kotlin
import io.github.cdimascio.dotenv.dotenv
import io.github.jan.supabase.auth.Auth
import io.github.jan.supabase.createSupabaseClient
import io.github.jan.supabase.postgrest.Postgrest

fun main() {

    val dotenv = dotenv()

    val supabase = createSupabaseClient(
        supabaseUrl = dotenv["URL"],
        supabaseKey = dotenv["KEY"]
    ) {
        install(Auth)
        install(Postgrest)
        //install(Storage)
    }
}

Got to the Supabase dashboard and copy your project’s URL and key.

Test that the supabase client is working by running the code.

Database

Create a new table with the SQL Editor:

sql
create table if not exists dog (
  id serial primary key,
  name text not null
)

Estàs llegint una vista prèvia.

Inicia sessió amb Google per llegir la pàgina completa.

Inicia sessió amb Google

Amb qualsevol compte de Google. Només et demanarem que acceptis les condicions del servei.