1# VpnExtensionContext 2 3**VpnExtensionContext** represents the context of **VpnExtensionAbility** and is inherited from [ExtensionContext](../apis-ability-kit/js-apis-inner-application-extensionContext.md). 4 5This module provides the context required for APIs to access the resources of a **VpnExtensionAbility** object. 6 7> **NOTE** 8> 9> 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. 10> The APIs of this module can be used only in the stage model. 11 12## Modules to Import 13```ts 14import { VpnExtensionAbility } from '@kit.NetworkKit'; 15``` 16## How to Use 17 18You can obtain a **VpnExtensionContext** object through a **VpnExtensionAbility** child class instance. 19 20```ts 21import { VpnExtensionAbility, vpnExtension } from '@kit.NetworkKit'; 22import { Want } from '@kit.AbilityKit'; 23 24export default class MyVpnExtAbility extends VpnExtensionAbility { 25 private vpnServerIp: string = 'xxx.xxx.x.x'; 26 private tunIp: string = 'x.x.x.x'; 27 private blockedAppName: string = 'xxxx'; 28 29 onCreate(want: Want) { 30 let VpnConnection: vpnExtension.VpnConnection = vpnExtension.createVpnConnection(this.context); 31 console.info("vpn createVpnConnection: " + JSON.stringify(VpnConnection)); 32 } 33} 34``` 35 36## VpnExtensionAbility 37 38Represents the VPN extension capability. 39 40**System capability**: SystemCapability.Ability.AbilityRuntime.Core. 41 42**Model restriction**: This API can be used only in the stage model. 43 44| Name | Type | Mandatory| Description | 45|------| ------------------------------------------------------------ | ---- | -------------- | 46| context | [VpnExtensionContext](js-apis-inner-application-VpnExtensionContext.md) | Yes | Specified context.| 47 48 49### onCreate 50 51onCreate(want: Want): void 52 53Represents the callback triggered when the extended VPN is initialized. 54 55**System capability**: SystemCapability.Ability.AbilityRuntime.Core. 56 57**Model restriction**: This API can be used only in the stage model. 58 59**Parameters** 60 61| Name| Type | Mandatory| Description | 62| ------ | ----------------------------------- | ---- |-----------| 63| want | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Want information.| 64 65### onDestroy 66 67onDestroy(): void 68 69Represents the callback triggered when the extended VPN is destroyed. 70 71**System capability**: SystemCapability.Ability.AbilityRuntime.Core. 72 73**Model restriction**: This API can be used only in the stage model. 74