Skip to main content
The official Kotlin SDK for TrailBase provides a type-safe, coroutine-based client for accessing your TrailBase backend from JVM, Android, and multiplatform Kotlin applications.

Installation

Gradle (Kotlin DSL)

Add to your build.gradle.kts:

Gradle (Groovy)

Add to your build.gradle:

Maven

Requirements

  • Kotlin 2.1+
  • Ktor client (automatically included)
  • kotlinx.serialization (automatically included)

Initialization

Basic Client

Client with Tokens

Authentication

Login

Logout

Current User

Access Tokens

Refresh Token

Record API

Define Your Record Types

List Records

Read a Record

Create a Record

Update a Record

Delete a Record

Filtering

Available Comparison Operators

Error Handling

Type Definitions

User

Tokens

ListResponse

Pagination

RecordId

Android Integration

Best Practices

Use Kotlin coroutines for all async operations. The SDK is built with coroutines in mind.
Store tokens securely using Android’s EncryptedSharedPreferences or KeyStore on Android, and appropriate secure storage on other platforms.
The client automatically refreshes auth tokens before they expire.

Example Application