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 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.

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 *