Initialization

Initialize the Vizco SDK with your base URL and API key.

Before using any Vizco composables, you must initialize the SDK with your backend URL and API key.

Basic setup

Call Vizco.init() in your Application class:

MyApp.kt
import android.app.Application
import com.vizco.sdk.Vizco

class MyApp : Application() {
  override fun onCreate() {
      super.onCreate()
      Vizco.init(
          baseUrl = "https://your-api.com",
          apiKey = "pk_550e8400e29b41d4a716446655440000"
      )
  }
}

Init before use

You must call Vizco.init() before any VizcoWidget composable is rendered. Failing to do so will throw an IllegalStateException.

Parameters

NameTypeDefaultDescription
baseUrl*StringYour Vizco backend URL. Trailing slashes are automatically trimmed.
apiKey*StringA project-scoped API key (pk_ format) with at least READ permissions.

Per-widget overrides

You can override the base URL and API key on individual widgets. This is useful if your app fetches widgets from multiple projects:

VizcoWidget(
  widgetSlug = "hero-carousel",
  baseUrl = "https://other-api.com",
  apiKey = "pk_another_project_key_here"
)

Register the Application class

Make sure your custom Application class is registered in AndroidManifest.xml:

AndroidManifest.xml
<application
  android:name=".MyApp"
  ...>

Next steps