<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/EnvironmentObject",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI17EnvironmentObjectV"
  },
  "title" : "EnvironmentObject"
}
-->

# EnvironmentObject

A property wrapper type for an observable object that a parent or ancestor
view supplies.

```
@MainActor @frozen @propertyWrapper @preconcurrency struct EnvironmentObject<ObjectType> where ObjectType : ObservableObject
```

## Overview

An environment object invalidates the current view whenever the observable
object that conforms to
<doc://com.apple.documentation/documentation/Combine/ObservableObject>
changes. If you declare a property as an environment object, be sure
to set a corresponding model object on an ancestor view by calling its
[`environmentObject(_:)`](/documentation/SwiftUI/View/environmentObject(_:)) modifier.

> Note: If your observable object conforms to the
> <doc://com.apple.documentation/documentation/Observation/Observable>
> protocol, use ``doc://com.apple.SwiftUI/documentation/SwiftUI/Environment`` instead of `EnvironmentObject` and set the
> model object in an ancestor view by calling its ``doc://com.apple.SwiftUI/documentation/SwiftUI/View/environment(_:)``
> or ``doc://com.apple.SwiftUI/documentation/SwiftUI/View/environment(_:_:)`` modifiers.

## Topics

### Creating an environment object

[`init()`](/documentation/SwiftUI/EnvironmentObject/init())

Creates an environment object.

### Getting the value

[`wrappedValue`](/documentation/SwiftUI/EnvironmentObject/wrappedValue)

The underlying value referenced by the environment object.

[`projectedValue`](/documentation/SwiftUI/EnvironmentObject/projectedValue)

A projection of the environment object that creates bindings to its
properties using dynamic member lookup.

[`Wrapper`](/documentation/SwiftUI/EnvironmentObject/Wrapper)

A wrapper of the underlying environment object that can create bindings
to its properties using dynamic member lookup.

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`DynamicProperty`](/documentation/SwiftUI/DynamicProperty)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

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)