github-webhook-handler is a Node.js library providing a minimalist handler or middleware for processing GitHub Webhooks. It simplifies the process of receiving and verifying webhook requests, acting as an EventEmitter for various GitHub events such as `push` or `issues`. The current stable version is 2.1.1, released in April 2026, following a major v2.0.0 release in January 2026 that introduced ESM support, promises, and updated Node.js requirements (>=20). This package differentiates itself by focusing specifically on GitHub webhooks, handling SHA-1 HMAC signature verification and event parsing, allowing developers to quickly integrate webhook processing into their Node.js applications without dealing with low-level HTTP request body parsing and security checks. It features a straightforward API for creating a handler function that can be integrated into standard Node.js HTTP servers, designed for developers who need a robust, event-driven way to react to GitHub repository activity.
npm install github-webhook-handlerVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to set up a basic Node.js HTTP server to listen for GitHub webhooks, create a handler, and respond to 'push' and 'issues' events, including error handling.
Migrate your project to use ES Modules (e.g., `"type": "module"` in `package.json`) and update your Node.js environment to version 20 or higher. Change `require()` statements to `import`.
Ensure the `secret` string provided to `createHandler({ secret: '...' })` exactly matches the 'Secret' configured in your GitHub repository's webhook settings. For security, retrieve secrets from environment variables rather than hardcoding.In your GitHub repository's webhook settings, under 'Content type', select 'application/json'.
Always register an error handler: `handler.on('error', (err) => console.error('Webhook error:', err))`.Update your project to use ES Modules with `import createHandler from 'github-webhook-handler'` and ensure your `package.json` has `"type": "module"` if running in Node.js >=12, or use a `.mjs` file extension.
Provide a non-empty string for the `secret` option: `createHandler({ path: '/webhook', secret: 'your_github_secret' })`. This secret must match the one configured in GitHub.Double-check that the `secret` value in your code precisely matches the 'Secret' configured in your GitHub webhook settings. Also, ensure the content type in GitHub is `application/json`.
Ensure your event listeners or the `next` callback only handle the response once. For instance, if an event listener processes the request, it should handle `res.end()`, and the `next` callback should be designed not to interfere if the request was successfully handled by the webhook.
No dependency data recorded yet.