Skip to main content

SignedIn

The SignedIn component conditionally renders its content only when the user is authenticated. It reads the current sign-in state from ThunderIDState and displays protected UI for signed-in users, while rendering optional fallback content (or nothing) when the user is not authenticated.

SignedIn requires .thunderIDProvider(config:) in its ancestor view hierarchy.

Usage

import SwiftUI
import ThunderIDSwiftUI

struct ContentView: View {
var body: some View {
SignedIn {
Text("You are signed in.")
}
}
}

When the user is not signed in, nothing is rendered unless you provide a fallback closure.

Parameters

ParameterTypeRequiredDescription
content@ViewBuilder () -> ContentThe view to render when the user is authenticated.
fallback@ViewBuilder () -> FallbackThe view to render when the user is not authenticated. Defaults to EmptyView.

Providing a Fallback

Show alternative content when the user is not signed in:

SignedIn {
HomeView()
} fallback: {
AuthView()
}

Example: Route Between Screens

Use SignedIn and SignedOut together to implement your app's root routing logic:

struct RootView: View {
@EnvironmentObject var state: ThunderIDState

var body: some View {
if !state.isInitialized {
ProgressView("Loading...")
} else {
SignedIn {
HomeView()
} fallback: {
AuthView()
}
}
}
}
ThunderID LogoThunderID Logo

Product

DocsAPIsSDKs
© WSO2 LLC. All rights reserved.Privacy PolicyCookie Policy