---
title: networkhotplug
slug: develop/networkhotplug
docTags: 
createdAt: 2025-03-26T14:45:45.001Z
---

The *networkhotplug* object can be used to generate events when a [network interface](docId\:U6ZceYQddlz9xdAKtTmJs) becomes available or unavailable. A *networkhotplugevent* will be generated, indicating the interface and whether it was attached or detached.

:::hint{type="info"}
Reconfiguring a network interface may cause it to detach and attach again.  A DHCP address renewal may cause an event, even if the IP address hasn't changed.
:::

**networkhotplug IDL**

```javascript
interface NetworkHotplugEvent {
    attribute String type;
    attribute bool attached; // 1 -> attached, 0 -> detached
    attribute String interfaceName;
};

callback NetworkHotplugEventCallback = void (NetworkHotplugEvent event);

interface NetworkHotplug {
    void addEventListener(String type, NetworkHotplugEventCallback callback);
    void removeEventListener(String type, NetworkHotplugEventCallback callback);
}; 
```

## Event Creation

To create a *networkhotplug* event, load the *@brightsign/networkhotplug* module using the Node.js® require() method:

```javascript
let networkhotplugClass = require("@brightsign/networkhotplug");
let networkhotplug = new networkhotplugClass();
```

## NetworkHotPlug 

Use this interface to configure a *networkhotplug* event.

- `networkhotplugevent`: This event is raised when the hotplug status changes. Use the `addEventListener()` method to listen for this event, or the `removeEventListener()` method to remove an event listener.

## NetworkHotPlugEvent Properties 

- `type` <font color="#6554c0">string</font>: Add or remove an event listener when this type of event occurs.
- `attached`<font color="#2166ae">:</font> Can be true or false (1 is attached, 0 is detached)
- `interfaceName` <font color="#6554c0">: </font>Returns the interface name (for example, "eth0")

## Example

```javascript
let networkhotplugClass = require("@brightsign/networkhotplug");
let networkhotplug = new networkhotplugClass();

networkhotplug.addEventListener("networkhotplugevent", onNetworkHotplugEvent);    

function onNetworkHotplugEvent(data) {
  if (data.attached)
{     // connected on 'data.interfaceName'   }
}
```

