1# @ohos.app.ability.VpnExtensionAbility (Enhanced VPN Management)
2
3This module provides lifecycle callbacks for third-party VPNs, including VPN creation and destruction.
4
5>  **NOTE**
6>
7>  - The initial APIs of this module are supported since API version 11. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8>
9>  - The APIs of this module can be used only in the stage model.
10
11## Modules to Import
12
13```ts
14import { VpnExtensionAbility } from '@kit.NetworkKit';
15```
16
17## Attributes
18
19**System capability**: SystemCapability.Ability.AbilityRuntime.Core.
20
21| Name| Type| Readable| Writable| Description|
22| -------- | -------- | -------- | -------- | -------- |
23| context | [VpnExtensionContext](js-apis-inner-application-VpnExtensionContext.md) | Yes| No| Context of the **VpnExtension**. This context is inherited from **ExtensionContext**.|
24
25## VpnExtensionAbility.onCreate
26
27onCreate(want: Want): void
28
29Called when the third-party VPN is initialized upon startup.
30
31**System capability**: SystemCapability.Ability.AbilityRuntime.Core
32
33**Parameters**
34
35| Name | Type                                      | Mandatory  | Description            |
36| ---- | ---------------------------------------- | ---- | -------------- |
37| want   | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes  | Want information.|
38
39**Example**
40
41  ```ts
42import { VpnExtensionAbility } from '@kit.NetworkKit';
43import { Want } from '@kit.AbilityKit';
44
45class MyVpnExtAbility extends VpnExtensionAbility {
46    onCreate(want: Want) {
47       console.log('MyVpnExtAbility onCreate');
48    }
49}
50  ```
51
52## VpnExtensionAbility.onDestroy
53
54onDestroy(): void
55
56Called when the third-party VPN is destroyed to clear resources.
57
58**System capability**: SystemCapability.Ability.AbilityRuntime.Core
59
60**Example**
61
62  ```ts
63import { VpnExtensionAbility } from '@kit.NetworkKit';
64
65class MyVpnExtAbility extends VpnExtensionAbility {
66    onDestroy() {
67       console.log('MyVpnExtAbility onDestroy');
68    }
69}
70  ```
71