---
title: connection
framework: avfoundation
role: symbol
role_heading: Instance Property
path: avfoundation/avcapturevideopreviewlayer/connection
---

# connection

An object that describes the connection from the layer to a particular input port.

## Declaration

```swift
var connection: AVCaptureConnection? { get }
```

## Mentioned in

Setting up a capture session

## Discussion

Discussion When you associate a preview layer with a capture session, the session automatically creates a connection to the first eligible video AVCaptureInput.Port object. If you detach a preview layer from a session, the connection property becomes nil.

## See Also

### Session configuration

- [session](avfoundation/avcapturevideopreviewlayer/session.md)
- [setSessionWithNoConnection(_:)](avfoundation/avcapturevideopreviewlayer/setsessionwithnoconnection(_:).md)
