whatisgithub

What is hammer.js?

hammerjs/hammer.js — explained in plain English

Analysis updated 2026-06-21

24,359JavaScriptAudience · developerComplexity · 2/5Setup · easy

In one sentence

Hammer.js is a JavaScript library that detects touch gestures like swipes, taps, pinches, and presses on web pages, so you can build mobile-friendly interactions without writing complex low-level code.

Mindmap

mindmap
  root((hammer.js))
    What it does
      Detect touch gestures
      Handle raw events
      No dependencies
    Gestures
      Tap and double tap
      Swipe directions
      Pinch and rotate
      Press and hold
    Use Cases
      Mobile carousels
      Pinch to zoom
      Drag and drop
      Touch menus
    Tech Stack
      JavaScript
      Any web project
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Build a touch-driven image carousel that responds to left and right swipe gestures on mobile devices.

USE CASE 2

Add pinch-to-zoom functionality to a photo viewer in a web app.

USE CASE 3

Create a drag-and-drop interface that works correctly on both mouse and touchscreen devices.

USE CASE 4

Define a custom triple-tap gesture to trigger a hidden action in your web app.

What is it built with?

JavaScript

How does it compare?

hammerjs/hammer.jsvercel/pkgwinstonjs/winston
Stars24,35924,37924,437
LanguageJavaScriptJavaScriptJavaScript
Setup difficultyeasyeasyeasy
Complexity2/52/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min
License not mentioned in the explanation.

So what is it?

Hammer.js is a JavaScript library that makes it easy to detect touch and gesture interactions on web pages. Normally, tracking gestures like swipes, taps, pinches, or presses involves writing complicated low-level code to interpret raw touch events from the browser. Hammer.js handles all that complexity so you can simply say "when the user swipes left, do this" without worrying about the underlying mechanics. It works by attaching a listener to any HTML element on your page. You then subscribe to named gesture events, tap, double tap, press, swipe, and so on, and provide a function to run when that gesture is detected. For custom gestures not included by default, you can define your own recognizers with specific rules (for example, a triple tap). You would use this when building a web app that needs to feel native on mobile devices: touch-driven carousels, drag-and-drop interfaces, pinch-to-zoom image viewers, or any interactive experience where mouse clicks aren't enough. It is a pure JavaScript library with no framework dependency, so it works with any web project.

Copy-paste prompts

Prompt 1
Using Hammer.js, add swipe-left and swipe-right detection to a div element so I can build a mobile card-swipe interface in JavaScript.
Prompt 2
How do I use Hammer.js to enable pinch-to-zoom on an image element in a web page?
Prompt 3
I want to detect a press-and-hold gesture with Hammer.js and show a context menu after 500 milliseconds. How do I configure that recognizer?
Prompt 4
Show me how to define a custom recognizer in Hammer.js for a triple-tap gesture and run a JavaScript function when it fires.

Frequently asked questions

What is hammer.js?

Hammer.js is a JavaScript library that detects touch gestures like swipes, taps, pinches, and presses on web pages, so you can build mobile-friendly interactions without writing complex low-level code.

What language is hammer.js written in?

Mainly JavaScript. The stack also includes JavaScript.

What license does hammer.js use?

License not mentioned in the explanation.

How hard is hammer.js to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is hammer.js for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.