https://github.com/enfp-dev-studio/node-mac-virtual-display
A Node native module to create virutal display of macOS
https://github.com/enfp-dev-studio/node-mac-virtual-display
display macos native node-addon-api nodejs osx virtual-display
Last synced: about 1 month ago
JSON representation
A Node native module to create virutal display of macOS
- Host: GitHub
- URL: https://github.com/enfp-dev-studio/node-mac-virtual-display
- Owner: enfp-dev-studio
- License: mit
- Created: 2022-12-11T07:26:15.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2026-02-04T05:10:14.000Z (3 months ago)
- Last Synced: 2026-02-04T05:58:07.392Z (3 months ago)
- Topics: display, macos, native, node-addon-api, nodejs, osx, virtual-display
- Language: Objective-C++
- Homepage:
- Size: 236 KB
- Stars: 48
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# node-mac-virtual-display: Native Library for Virtual Display on macOS
A native library for macOS to create virtual displays for your applications using Node.js. This library uses CoreGraphics and CoreDisplay APIs to provide an interface for creating and managing virtual displays on macOS. This library is used in [Tab Display](https://tab-display.enfpdev.com), a service that allows iPads and Android tablets to be used as portable monitors.
## Features
- [x] Create and Destroy single virtual displays on macOS.
- [x] Configurable display resolution and refresh rate.
- [x] Create a virtual display by cloning the main display.
- [x] Added option to select between Mirror and Extend display modes
- [ ] Support for multiple virtual displays.
## Requirements
- macOS 10.14 or later
- Node.js 12 or later
## Installation
Use npm to install the library:
```shell
yarn add node-mac-virtual-display
```
## Usage
To create/destroy a virtual display:
```javascript
const VirtualDisplay = require('node-mac-virtual-display')
const vdisplay = new VirtualDisplay()
// Clone primary display
vdisplay.cloneVirtualDisplay({
displayName: "Clone Display",
mirror: true
})
// OR
// To create a virtual display:
vdisplay.createVirtualDisplay({
width: 1920,
height: 1080,
frameRate: 60,
hiDPI: true,
displayName: "Virtual Display",
mirror: false
})
//To destroy a virtual display:
vdisplay.destroyVirtualDisplay()
```
## Persistent Display Identity
This library now automatically uses the **Display Name** (`displayName`) as the persistent identity key.
- **Name-Based Persistence**: When you create a display with `displayName: "My Monitor"`, it receives a consistent internal ID derived from that name.
- **Mac Memory**: macOS will remember the window layout and resolution settings associated with that specific name.
- **Simple Usage**: Just use the same name next time, and your windows will be exactly where you left them.
### ⚠️ Note on Changing Resolutions
If you keep the same `displayName` but drastically change the resolution or aspect ratio (e.g., 16:9 -> 4:3), macOS might get confused because it thinks it's the same monitor. If you need a "fresh" monitor profile, simply give it a **new name** (e.g. "Monitor V2").
## Contribute
Coffee fuels coding ☕️
