Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

docs: update steps to setup

Hieu Vu4603f90653e3
diff --git a/apps/docs/pages/guides/getting-started/quickstarts/kotlin.mdx b/apps/docs/pages/guides/getting-started/quickstarts/kotlin.mdx
index e2dfa410a8e..1d43b086fde 100644
--- a/apps/docs/pages/guides/getting-started/quickstarts/kotlin.mdx
+++ b/apps/docs/pages/guides/getting-started/quickstarts/kotlin.mdx
@@ -2,35 +2,40 @@ import Layout from '~/layouts/DefaultGuideLayout'
import StepHikeCompact from '~/components/StepHikeCompact'
export const meta = {
- title: 'Use Supabase with Kotlin',
+ title: 'Use Supabase with Android Kotlin',
subtitle:
- 'Learn how to create a Supabase project, add some sample data to your database, and query the data from a Kotlin app.',
+ 'Learn how to create a Supabase project, add some sample data to your database, and query the data from a Android Kotlin app.',
breadcrumb: 'Framework Quickstarts',
}
<StepHikeCompact>
<StepHikeCompact.Step step={1}>
- <StepHikeCompact.Details title="Set up a Supabase project with sample data">
+ <StepHikeCompact.Details title="Set up a Supabase project">
[Create a new project](https://app.supabase.com) in the Supabase Dashboard.
- After your project is ready, create a table in your Supabase database using the [SQL Editor](https://app.supabase.com/project/_/sql) in the Dashboard. Use the following SQL statement to create a `countries` table with some sample data.
+ After your project is ready, create a table in your Supabase database using the [SQL Editor](https://app.supabase.com/project/_/sql) in the Dashboard. Use the following SQL statement to create all tables.
</StepHikeCompact.Details>
<StepHikeCompact.Code>
```sql SQL_EDITOR
- -- Create the table
- CREATE TABLE countries (
- id SERIAL PRIMARY KEY,
- name VARCHAR(255) NOT NULL
- );
- -- Insert some sample data into the table
- INSERT INTO countries (name) VALUES ('United States');
- INSERT INTO countries (name) VALUES ('Canada');
- INSERT INTO countries (name) VALUES ('Mexico');
+ -- Create products table
+ create table
+ public.products (
+ _id bigint generated by default as identity not null,
+ productid text not null,
+ name text null,
+ description text null,
+ price real null,
+ image text null,
+ category text null,
+ nutrition text null,
+ constraint products_pkey primary key (productid),
+ ) tablespace pg_default;
+
````
</StepHikeCompact.Code>
@@ -39,34 +44,54 @@ export const meta = {
<StepHikeCompact.Step step={2}>
- <StepHikeCompact.Details title="Create a Flutter app">
+ <StepHikeCompact.Details title="Create an Android app with Android Studio">
+ Setup environment for Android Development following official document.
+ Open Android Studio > New > New Android Project
+
+ </StepHikeCompact.Details>
+
+ </StepHikeCompact.Step>
- ...
+ <StepHikeCompact.Step step={3}>
+ <StepHikeCompact.Details title="Install the Supabase client library">
+ Setup Supabase libraries requires some others libraries from ktor, so make sure all dependencies are added
+
</StepHikeCompact.Details>
<StepHikeCompact.Code>
- ```bash Terminal
- ...
+ ```kotlin
+ implementation("io.ktor:ktor-client-cio:1.6.0")
+ implementation("io.github.jan-tennert.supabase:postgrest-kt-android:0.9.0-alpha-4")
+ implementation "io.ktor:ktor-client-android:2.2.1"
+ implementation "io.ktor:ktor-utils-jvm:1.6.0"
+ implementation "io.ktor:ktor-client-logging-jvm:1.6.0"
+ implementation("io.ktor:ktor-client-core:2.2.4")
```
</StepHikeCompact.Code>
</StepHikeCompact.Step>
- <StepHikeCompact.Step step={3}>
-
- <StepHikeCompact.Details title="Install the Supabase client library">
-
- ...
+ <StepHikeCompact.Step step={4}>
+ <StepHikeCompact.Details title="Initialize the Supabase client">
+ You can create a whenever you need to perform some API call.
+ However, it is recommended that we should provide this kind of instance by using dependency injection library like Hilt. So see the code below to provide them properly. This is better for testability and maintainability
</StepHikeCompact.Details>
<StepHikeCompact.Code>
```kotlin
- ...
+ // Handy create instance when need
+ val client = createSupabaseClient(
+ supabaseUrl = "https://xyzcompany.supabase.co",
+ supabaseKey = "public-anon-key") {
+ install(GoTrue)
+ install(Postgrest)
+ //install other modules
+ }
```
</StepHikeCompact.Code>
@@ -75,16 +100,30 @@ export const meta = {
<StepHikeCompact.Step step={4}>
- <StepHikeCompact.Details title="Initialize the Supabase client">
-
- ...
-
+ <StepHikeCompact.Details title="Create data transfer object">
</StepHikeCompact.Details>
<StepHikeCompact.Code>
-
- ```kotlin MainActivity.kt
- ...
+ ```kotlin
+ @Serializable
+ data class ProductDto(
+ @SerialName("productid")
+ val productId: String,
+ @SerialName("name")
+ val name: String,
+ @SerialName("description")
+ val description: String,
+ @SerialName("price")
+ val price: Double,
+ @SerialName("image")
+ val image: String,
+ @SerialName("category")
+ val category: String,
+ @SerialName("nutrition")
+ val nutrition: String,
+ @SerialName("_id")
+ val _id: Int,
+ )
```
</StepHikeCompact.Code>
@@ -94,34 +133,26 @@ export const meta = {
<StepHikeCompact.Step step={5}>
<StepHikeCompact.Details title="Query data from the app">
-
- ...
-
+
</StepHikeCompact.Details>
<StepHikeCompact.Code>
-
- ```kotlin MainActivity.kt
- ...
+ ```kotlin
+ override suspend fun getProducts() {
+ val result = supabasePostgrest["products"]
+ .select().decodeList<ProductDto>()
+ // Handle result data for next step
+ }
```
-
</StepHikeCompact.Code>
</StepHikeCompact.Step>
- <StepHikeCompact.Step step={6}>
+ <StepHikeCompact.Step step={7}>
<StepHikeCompact.Details title="Start the app">
</StepHikeCompact.Details>
- <StepHikeCompact.Code>
-
- ```bash Terminal
- ...
- ```
-
- </StepHikeCompact.Code>
-
</StepHikeCompact.Step>
</StepHikeCompact>