How to copy to clipboard in Node.js?

Sometimes, we want to copy to clipboard in Node.js.

In this article, we’ll look at how to copy to clipboard in Node.js.

How to copy to clipboard in Node.js?

To copy to clipboard in Node.js, we can use the clipboardy package.

To install it, we run

npm i clipboardy

Then we run it by writing

const clipboardy = require('clipboardy');

clipboardy.writeSync('hello');
clipboardy.readSync();

to call writeSync with the string we want to copy to the clipboard.

Then we read the clipboard content with readSync.

Conclusion

To copy to clipboard in Node.js, we can use the clipboardy package.