---
title: EnvironmentObject
framework: swiftui
role: symbol
role_heading: Structure
path: swiftui/environmentobject
---

# EnvironmentObject

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

## Declaration

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

## Overview

Overview An environment object invalidates the current view whenever the observable object that conforms to 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(_:) modifier. note: If your observable object conforms to the Observable protocol, use Environment instead of EnvironmentObject and set the model object in an ancestor view by calling its environment(_:) or environment(_:_:) modifiers.

## Topics

### Creating an environment object

- [init()](swiftui/environmentobject/init().md)

### Getting the value

- [wrappedValue](swiftui/environmentobject/wrappedvalue.md)
- [projectedValue](swiftui/environmentobject/projectedvalue.md)
- [EnvironmentObject.Wrapper](swiftui/environmentobject/wrapper.md)

## Relationships

### Conforms To

- [DynamicProperty](swiftui/dynamicproperty.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Distributing model data throughout your app

- [environmentObject(_:)](swiftui/view/environmentobject(_:).md)
- [environmentObject(_:)](swiftui/scene/environmentobject(_:).md)
