---
title: "init(_:contentType:source:prepareDocumentURL:)"
framework: swiftui
role: symbol
role_heading: Initializer
path: "swiftui/newdocumentbutton/init(_:contenttype:source:preparedocumenturl:)"
---

# init(_:contentType:source:prepareDocumentURL:)

Creates and opens new URL-based documents from a template picker.

## Declaration

```swift
nonisolated init(_ title: LocalizedStringKey, contentType: UTType, source: DocumentCreationSource, prepareDocumentURL: @escaping () async throws -> URL? = { nil })
```

## Parameters

- `title`: A title key for the button.
- `contentType`: The content type of the document to create.
- `source`: A source for the document creation flow. When a document is created, you can retrieve its source from doc://com.apple.SwiftUI/documentation/SwiftUI/FileDocumentConfiguration or doc://com.apple.SwiftUI/documentation/SwiftUI/URLDocumentConfiguration.
- `prepareDocumentURL`: Called when the user taps the button.
