How to install Hammer.js


Hammer.js is a open-source library that can recognize gestures made by touch, mouse and pointerEvents. It doesn’t have any dependencies, and it’s small, only 7.34 kB minified + gzipped!


You can download the latest version of Hammer.js from the GitHub releases or use a Hammer.js CDN.


Latest:2021-08-29 09:29:57
License:MIT License
Cloning with HTTPS URLs
git clone
Cloning with SSH URLs
git clone [email protected]:hammerjs/hammer.js.git
Cloning with GitHub CLI
gh repo clone hammerjs/hammer.js


Publish Time:2016-04-23 00:14:57
Unpacked Size:208.19 kB
Downloading and installing packages locally
npm i hammerjs
npm install hammerjs
yarn add hammerjs
Downloading and installing packages globally
npm i -g hammerjs
yarn global add hammerjs
Install Specific Version of a Package
npm install [email protected]
bower install hammerjs

For more information about Hammer.js see


Code 1: - It’s easy to use, just include the library and create a new instance.

var hammertime = new Hammer(myElement, myOptions);
hammertime.on('pan', function(ev) {

Code 2: - hammer.js has a quick start option for gestures it already recognizes.

// Get a reference to an element.
var square = document.querySelector('.square');

// Create an instance of Hammer with the reference.
var hammer = new Hammer(square);

// Subscribe to a quick start event: press, tap, or doubletap.
// For a full list of quick start events, read the documentation.
hammer.on('press', function(e) {'expand');
  console.log("You're pressing me!");