GrowthRailDocs

Installation

The SDK is published to Maven Central as two artifacts. Prefer the full growthrail artifact unless you are building a custom UI.

build.gradle.kts
repositories {
  google()
  mavenCentral()
}

dependencies {
  // Complete SDK: core APIs plus the native referral UI.
  implementation("dev.growthrail:growthrail:0.1.1")

  // Or, for a headless/custom UI integration:
  // implementation("dev.growthrail:growthrail-core:0.1.1")
}
Requirements: minSdk 23, compileSdk 35, JDK 17. Current Maven Central release is 0.1.1. Local development can use 0.1.0-SNAPSHOT from Maven Local.
ArtifactUse when
dev.growthrail:growthrailFull SDK including the View overlay host. Depends on growthrail-core transitively.
dev.growthrail:growthrail-coreAttribution and referral APIs only — you render your own UI and collect GrowthRail.state.

Configuration

Call GrowthRail.initialize once in your Application class. Use a publishable mobile key; never embed a server secret in the APK.

ExampleApplication.kt
import android.app.Application
import dev.growthrail.sdk.GrowthRail
import dev.growthrail.sdk.GrowthRailAppearance
import dev.growthrail.sdk.GrowthRailConfiguration
import dev.growthrail.sdk.GrowthRailTheme

class ExampleApplication : Application() {
  override fun onCreate() {
    super.onCreate()
    GrowthRail.initialize(
      this,
      GrowthRailConfiguration(
        projectSecretKey = "sk_your_publishable_mobile_key",
        appearance = GrowthRailAppearance.DARK,
        theme = GrowthRailTheme(primaryColor = "#2563eb"),
        debug = BuildConfig.DEBUG,
      ),
    )
  }
}

Configuration Options

OptionTypeDefaultDescription
projectSecretKeystringRequired Publishable mobile key (sk_...).
apiUrlstring?production APIOverride for staging or local API testing.
appearanceLIGHT | DARK?systemPreferred appearance for automatic UI.
theme.primaryColorstring?campaign / #2563ebHex primary color for trigger and dashboard chrome.
disableTriggerButtonbooleanfalseNever show the automatic floating/edge trigger.
userIdstring?nullIf set, identifies the user automatically after bootstrap.
debugbooleanfalseVerbose logging. Disable in production.
cookieDomain and autoPageTrack exist for React Native source compatibility and have no effect on Android.

Automatic UI

With the full growthrail artifact, attach the overlay after setContentView. The host renders the server-configured trigger, new-user banner, and referral dashboard.

kotlin
import dev.growthrail.sdk.ui.GrowthRailOverlay

override fun onCreate(savedInstanceState: Bundle?) {
  super.onCreate(savedInstanceState)
  setContentView(R.layout.activity_main)
  GrowthRailOverlay.attach(this)
}

It is safe to call attach more than once; it returns the existing host. You can also place GrowthRailHostView as the top-most child of a root FrameLayout.

FieldValuesBehavior
trigger.displayModefloating | edge | noneCircle inset trigger, flush edge tab, or hidden. Also respect disableTriggerButton.
trigger.positionbottom-right, bottom-left, top-right, top-leftCorner placement for the trigger.
modal.componentTypemodal | drawerCentered card over a dimmed backdrop, or bottom sheet with a drag handle (max ~90% height).
banner.positioncenter-top, center-bottom, left-*, right-*New-user promotional banner placement after attributed install/open.

User Management

Call initAppUser after authentication with a stable app user ID. Any attribution captured from an incoming link is bound automatically.

kotlin
lifecycleScope.launch {
  val user = GrowthRail.initAppUser(userId)
  val referralLink = GrowthRail.getReferralLink()
  val attributionToken = GrowthRail.getAttributionToken()
}

GrowthRail.state is a StateFlow with isInitialized, isUserReady, currentUser, isLoading, error, referral fields, trigger visibility, banner state, and dashboard state.

Common APIs

NeedAPI
Identify usersuspend GrowthRail.initAppUser(userId) or identify(userId)
Open / close dashboardshowReferralDashboard(options), hideReferralDashboard()
Incoming attributiongetReferralTrackingId(), getAttributionToken(), getCapturedReferralCode()
Current referral datagetReferralLink(), getReferralCode()
Track a non-standard sourcesuspend trackReferral(referralCode, rewardEventName)
Dismiss bannerdismissBanner()
Custom UICollect GrowthRail.state; optionally embed ReferralDashboard / TriggerButton

Dashboard options override

kotlin
GrowthRail.showReferralDashboard(
  ReferrerModalOptions(
    title = "Invite Friends",
    description = "Share your link and earn rewards.",
    componentType = ReferralDashboardPresentation.DRAWER,
    appearance = GrowthRailAppearance.DARK,
    theme = GrowthRailTheme(primaryColor = "#2563eb"),
  )
)

Deep Linking

Declare a custom scheme or verified App Link, then forward intents to GrowthRail. The handler returns false for URLs that do not contain a non-empty referralCode query parameter.

AndroidManifest.xml
<activity
    android:name=".MainActivity"
    android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="your-app" />
    </intent-filter>
</activity>
kotlin
override fun onCreate(savedInstanceState: Bundle?) {
  super.onCreate(savedInstanceState)
  intent.data?.let(GrowthRail::handleDeepLink)
}

override fun onNewIntent(intent: Intent) {
  super.onNewIntent(intent)
  intent.data?.let(GrowthRail::handleDeepLink)
}

On first launch the SDK checks Google Play Install Referrer, then uses the same privacy-preserving match-link fallback as React Native.

Emulator tip: adb shell am start -a android.intent.action.VIEW -d 'your-app://open?referralCode=TEST123'

Complete Example

MainActivity.kt
class MainActivity : AppCompatActivity() {
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)
    GrowthRailOverlay.attach(this)
    intent.data?.let(GrowthRail::handleDeepLink)

    lifecycleScope.launch {
      GrowthRail.initAppUser("user_123")
    }

    findViewById<Button>(R.id.invite).setOnClickListener {
      GrowthRail.showReferralDashboard()
    }
  }

  override fun onNewIntent(intent: Intent) {
    super.onNewIntent(intent)
    intent.data?.let(GrowthRail::handleDeepLink)
  }
}

Differences from React Native

FeatureReact NativeAndroid (Kotlin)
Distributionnpm (@growth-rail/react-native)Maven Central AARs
Entry pointGrowthRailProvider + hooksGrowthRail.initialize + GrowthRailOverlay.attach
StorageAsyncStorageSharedPreferences-backed storage
UIReact Native componentsView-system overlay host
Modal vs drawerCustom animated viewsCentered dialog vs bottom-gravity sheet

Troubleshooting