Categories
JavaScript Answers

How to copy to clipboard in Node.js?

Spread the love

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 use the clipboardy library.

To install it, we run

npm install clipboardy

Then we write

const clipboardy = require('clipboardy');

clipboardy.writeSync('hello world');

clipboardy.readSync();

to call clipboardy.writeSync to write 'hello world' to the clipboard.

And we call readSync to read the content of the clipboard.

Conclusion

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

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *