<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/TransientComponent",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation18TransientComponentP"
  },
  "title" : "TransientComponent"
}
-->

# TransientComponent

An interface for components that aren’t saved to file or cloned.

```
protocol TransientComponent : Component
```

## Overview

Components that conform to the [`TransientComponent`](/documentation/RealityKit/TransientComponent) protocol aren’t
included when RealityKit serializes its owning entity to save it to a file.
Similarly, when you clone an entity, any transient components on that entity
aren’t copied to the clone.

To ensure that cloned entities, or entities saved to file get a copy of the
transient component with default values, create and initialize the component
in your entity’s `init()` method:

```swift
class MyEntity: Entity {
    required init() {
        let newComponent = MyComponent()
        components[MyComponent.self] = newComponent
        return newComponent
    }
}
```

Alternatively, you can create a computed
property for your component that initializes it to default values the first
time your code accesses it.

```swift
class MyEntity: Entity {
    var myComponent: MyComponent {
        // If the component exists, return it.
        if let component = components[MyComponent.self] {
            return component
        }

        // Create a new component and return it.
        components[MyComponent.self] = MyComponent()
        return newComponent
    }
}
```

Use transient components to represent runtime state for an entity. For
example, an entity representing a fish in a virtual aquarium might store
attributes such as hunger in a transient component.

In networked AR experiences, RealityKit sends transient components to peers
when it sends the entity, if the component also conforms to
<doc://com.apple.documentation/documentation/Swift/Codable>. If transient
components don’t conform, ReaityKit still sends the entity to network peers,
but it excludes the transient component.

## Relationships

### Conforming Types

[`ComputeGraphViewpointComponent`](/documentation/RealityKit/ComputeGraphViewpointComponent)

[`ComputeGraphSharedUniforms`](/documentation/RealityKit/ComputeGraphSharedUniforms)

[`ARKitAnchorComponent`](/documentation/RealityKit/ARKitAnchorComponent)

[`ViewAttachmentComponent`](/documentation/RealityKit/ViewAttachmentComponent)

[`ComputeGraphOutputComponent`](/documentation/RealityKit/ComputeGraphOutputComponent)

[`PresentationComponent`](/documentation/RealityKit/PresentationComponent)

[`ComputeGraphRuntimeComponent`](/documentation/RealityKit/ComputeGraphRuntimeComponent)

### Inherits From

[`Component`](/documentation/RealityKit/Component)

---

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)