---
title: "snapshot(contentType:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/writabledocument/snapshot(contenttype:)"
---

# snapshot(contentType:)

Creates a snapshot of the document’s current state to be saved.

## Declaration

```swift
@MainActor func snapshot(contentType: UTType) async throws -> sending Self.Writer.Snapshot
```

## Parameters

- `contentType`: The format of the data requested.

## Discussion

Discussion SwiftUI calls this on the main actor when saving. Perform expensive serialization inside DocumentWriter.write(content:to:previous:progress:) rather than here.

## See Also

### Writing a document

- [writableContentTypes](swiftui/writabledocument/writablecontenttypes.md)
- [WritableDocument.WriteConfiguration](swiftui/writabledocument/writeconfiguration.md)
- [Writer](swiftui/writabledocument/writer.md)
- [writer(configuration:)](swiftui/writabledocument/writer(configuration:).md)
