How to create the copy and paste event in Nodejs?

In the article How to create action copy and paste in Javascript? we have learned about how to create the copy and paste event in Javascript, but it just work on client side, not work in server side. If we use Nodejs server, how we can do it?
Fortunately, in the Nodejs, we have a package called copy-to-clipboard, a simple module exposing copy function that will try to use execCommand with fallback to IE-specific clipboardData interface and finally, resort to usual prompt with proper text content and message. Let see how to use it.

Install: yarn add copy-to-clipboard or npm i --save copy-to-clipboard

import copy from 'copy-to-clipboard';

copy('Text string');

Use with options:

import copy from 'copy-to-clipboard';

copy('Text string', {
  debug: true,
  message: 'Press #{key} to copy',

View more document:

© 2019 4codev

Created with love by Sil.