Skip to main content

Watch Connectivity

Use Watch Connectivity to keep an iOS app and its companion watchOS app signed in as the same user. When a user signs in or out on either device, the other device follows.

Important

This guide is for companion watch apps that pair with an iPhone app. Standalone watch apps must authenticate separately and do not use Watch Connectivity sync.

Confirm a companion watch app

Watch Connectivity only works when your watchOS target is a companion to the iOS app. Make sure your iOS app target is paired with a watchOS target in Xcode. For Apple’s guidance on setting up a companion watch app, see Setting up a watchOS project.

Configure Clerk in both apps

Use the same in both apps and enable watch sync in Clerk.Options:

import ClerkKit
import SwiftUI

@main
struct WatchConnectivityExampleApp: App {
  init() {
    // Configure Clerk with Watch Connectivity sync enabled
    let options = Clerk.Options(
      watchConnectivityEnabled: true
    )

    Clerk.configure(
      publishableKey: "YOUR_PUBLISHABLE_KEY",
      options: options
    )
  }

  var body: some Scene {
    WindowGroup {
      ContentView()
        .environment(Clerk.shared)
    }
  }
}
import ClerkKit
import SwiftUI

@main
struct WatchConnectivityExampleWatchApp: App {
  init() {
    // Configure Clerk with Watch Connectivity sync enabled
    let options = Clerk.Options(
      watchConnectivityEnabled: true
    )

    Clerk.configure(
      publishableKey: "YOUR_PUBLISHABLE_KEY",
      options: options
    )
  }

  var body: some Scene {
    WindowGroup {
      ContentView()
        .environment(Clerk.shared)
    }
  }
}

Simulator setup (optional)

For simulator testing, make sure your iPhone simulator is paired with a watchOS simulator in Xcode > Window > Devices and Simulators.

Install and run

  1. Build and run the iOS app first (this installs the companion watch app).
  2. Then run the watchOS app.
  3. Sign in on either device to verify the session syncs.

Note

If you see "WCSession counterpart app not installed", install the iOS app first.

Feedback

What did you think of this content?

Last updated on