---
title: DevicePicker
framework: devicediscoveryui
role: symbol
role_heading: Structure
path: devicediscoveryui/devicepicker
---

# DevicePicker

A SwiftUI view that displays other devices on the network, and creates an encrypted connection to a copy of your app running on that device.

## Declaration

```swift
@MainActor @preconcurrency struct DevicePicker<Label, Fallback> where Label : View, Fallback : View
```

## Mentioned in

Connecting a tvOS app to other devices over the local network

## Overview

Overview Always display the picker as a full-screen, modal view. If the user selects a device, the system calls the closure you passed as the onSelect parameter. If the user cancels the picker, it silently closes. DevicePicker(     .applicationService(name: "MyAppService")) { endpoint in         myDeviceManager.connectTo(endpoint: endpoint)     } label: {         Text("Connect to a local device.")     } fallback: {         Text("Not supported.")     } parameters: {         // This example uses the default application services parameters;         // however, you can add a NWProtocolFramer to provide application-level         // messaging.         .applicationService     } If the current device doesn’t support device discovery, the system displays the fallback view instead of the device picker. Use the DevicePickerSupportedAction environment value to check whether the current device supports device discovery. struct SettingsView: View {

@Environment{\.devicePickerSupports} var myDevicePickerSupports     @Binding var showDevicePicker: Bool

var body: some View {         if myDevicePickerSupports(.applicationService("MyAppService"),                                   parameters: { .applicationService }) {             Button("Select A Device") {                 // Display a device picker.                 showDevicePicker = true             }         }     } }

## Topics

### Creating a device picker

- [init(_:onSelect:label:fallback:parameters:)](devicediscoveryui/devicepicker/init(_:onselect:label:fallback:parameters:).md)
- [init(_:access:onSelect:label:fallback:parameters:)](devicediscoveryui/devicepicker/init(_:access:onselect:label:fallback:parameters:).md)

## Relationships

### Conforms To

- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
- [View](swiftui/view.md)

## See Also

### Pairing with nearby devices

- [DDDevicePickerViewController](devicediscoveryui/dddevicepickerviewcontroller.md)
- [DevicePickerSupportedAction](devicediscoveryui/devicepickersupportedaction.md)
- [Connecting a tvOS app to other devices over the local network](devicediscoveryui/connecting-a-tvos-app-to-other-devices-over-the-local-network.md)
