---
title: "init(viewing:contentType:viewer:)"
framework: swiftui
role: symbol
role_heading: Initializer
path: "swiftui/documentgroup/init(viewing:contenttype:viewer:)"
---

# init(viewing:contentType:viewer:)

Instantiates a document group for viewing documents that store a specific model type.

## Declaration

```swift
nonisolated init(viewing modelType: any PersistentModel.Type, contentType: UTType, viewer: @escaping () -> Content)
```

## Parameters

- `modelType`: The model type defining the schema used for each document.
- `contentType`: The content type of document your app can view. It should conform to UTType.package.
- `viewer`: The viewing UI for the provided document.

## Discussion

Discussion  @main  struct Todo: App {      var body: some Scene {          DocumentGroup(viewing: TodoItem.self, contentType: .todoItem) {              ContentView()          }      }  }

extension UTType {      static var todoItem = UTType(exportedAs: "com.myApp.todoItem")  } important: If your app declares custom uniform type identifiers, include corresponding entries in the app’s Info.plist. For more information, see Defining file and data types for your app. Also, remember to specify the supported Document types in the Info.plist as well.

## See Also

### Viewing a document backed by a persistent store

- [init(viewing:migrationPlan:viewer:)](swiftui/documentgroup/init(viewing:migrationplan:viewer:).md)
