<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "NetworkExtension",
  "identifier" : "/documentation/NetworkExtension/NEVPNManager/saveToPreferences(completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Network Extension"
    ],
    "preciseIdentifier" : "c:objc(cs)NEVPNManager(im)saveToPreferencesWithCompletionHandler:"
  },
  "title" : "saveToPreferences(completionHandler:)"
}
-->

# saveToPreferences(completionHandler:)

Save the VPN configuration in the Network Extension preferences.

```
func saveToPreferences(completionHandler: (@Sendable ((any Error)?) -> Void)? = nil)
```

## Parameters

`completionHandler`

An optional block that takes an <doc://com.apple.documentation/documentation/Foundation/NSError> object. If specified, this block will be executed on the caller’s main thread after the save operation is complete. If the configuration could not be saved to the preferences, the error parameter will be set to an `NSError` object containing details about the error. See `NEVPN Errors` for a list of possible errors. If the configuration is saved successfully then the error parameter will be set to nil.

## Discussion

You must call [`loadFromPreferences(completionHandler:)`](/documentation/NetworkExtension/NEVPNManager/loadFromPreferences(completionHandler:)): at least once before calling this method the first time after your app launches.

## See Also

[`NEVPNManager`](/documentation/NetworkExtension/NEVPNManager)

An object to create and manage a Personal VPN configuration.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)