Initialization

Configure the Vizco iOS SDK with your API key.

Before rendering widgets, configure the SDK with your project's API key. There are two approaches — global configuration and per-view provider.

Global configuration

Call Vizco.configure(apiKey:) once at app startup, typically in your App struct:

MyApp.swift
import SwiftUI
import VizcoSDK

@main
struct MyApp: App {
  init() {
      Vizco.configure(apiKey: "pk_your_api_key")
  }

  var body: some Scene {
      WindowGroup {
          ContentView()
      }
  }
}

This sets up the HTTP client, widget cache, and analytics engine globally.

SwiftUI environment provider

Alternatively, use the .vizcoProvider(apiKey:) view modifier to scope configuration to a view hierarchy:

ContentView.swift
import SwiftUI
import VizcoSDK

struct ContentView: View {
  var body: some View {
      NavigationStack {
          HomeView()
      }
      .vizcoProvider(apiKey: "pk_your_api_key")
  }
}

The provider injects the client, cache, and analytics into the SwiftUI environment. Widgets within the view hierarchy will use this configuration automatically.

The environment provider takes precedence over global configuration. Use it when you need different API keys in different parts of your app.

Next steps