<!--
{
  "availability" : [
    "iOS: 26.2.0 -",
    "iPadOS: 26.2.0 -",
    "macOS: 26.2.0 -",
    "visionOS: 26.2.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/EnvironmentValues/credentialDataManager",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "SwiftUI",
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI17EnvironmentValuesV024_AuthenticationServices_aB0E21credentialDataManagerAD010CredentialhI0Vvp"
  },
  "title" : "credentialDataManager"
}
-->

# credentialDataManager

This environment variable is for SwiftUI clients of the ASCredentialDataManager API. An example usage might look like:

```
var credentialDataManager: CredentialDataManager { get }
```

## Discussion

```
struct CredentialDataManagerExample: View {
    @Environment(\.credentialDataManager) private var credentialDataManager

    var body: some View {
        Button("Save Credentials") {
            Task {
                do {
                    let credential = getCredential() // defined elsewhere
                    let scope = getScope()
                    try await credentialDataManager.save(credential: credential, for: scope)
                } catch {
                    // code to handle the save error
                }
            }
        }
    }
}
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)