Clipboard.js lets you copy text to clipboard. It’s tiny at 2KB and doesn’t use Flash. Here’s how to use it in your next Meteor project.

First, create the Meteor project “demo.”

meteor create demo
cd demo

Add the Clipboard.js CDN link to the HEAD of your demo.html file and create a new button.

# demo.html
  <script src="//"></script>

  <h1>Welcome to Meteor!</h1>
  {{> hello}}

<template name="hello">
  <button class="btn-copy-link" data-clipboard-text="">Copy</button>
  <button>Click Me</button>
  <p>You've pressed the button  times.</p>

Now to make it work in Meteor add an onRendered function to “demo.js”:

if (Meteor.isClient) {
  Template.hello.onRendered(function() {
    var clipboard = new Clipboard('.btn-copy-link');

And BOOM we’re done!

Want to improve your JavaScript? I have a list of recommended JavaScript books.