# jpillora/xhook

Easily intercept and modify XHR request and response

Repository: https://github.com/jpillora/xhook
Canonical: https://ross.abutalabs.com/products/jpillora-xhook
Homepage: http://jpillora.com/xhook
Language: HTML
License: MIT
License Family: permissive
Last push: 2024-07-06T03:33:26+00:00

## Health v2 (maintenance only)
Score: 23/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 0, release rhythm 8, longevity 100
- inputs: {"age_days": 4756, "days_push": 788, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1038, forks 152 (observed 2026-08-28T04:03:19.757054+00:00)

## What it is
XHook is a small JavaScript library that patches XMLHttpRequest to let you intercept and modify AJAX requests and responses in the browser. It supports before/after hooks, fake responses for testing, header injection, and works alongside fetch, jQuery, Angular, and web workers.

## Use cases
- intercept and modify xhr requests in the browser
- mock ajax responses for frontend testing
- add authentication headers to xhr requests
- cache ajax requests in localstorage
- simulate fake backend responses client-side
- log xhr error statistics to analytics

## When to choose
- you need to transparently patch XMLHttpRequest across an existing codebase
- you want to fake or modify AJAX responses without a server
- you need to inject headers or rewrite requests in legacy XHR-based apps

## When to avoid
- your code exclusively uses the fetch API instead of XMLHttpRequest
- you need full network-level interception in Node.js or service workers
- you want an actively developed library with ongoing feature work

## Facets
- artifact type: library
- maturity: maintenance
- function: http-client, middleware, mocking, caching
- domain: web-development, frontend, developer-tools, testing
- platform: browser
- tags: xhr, ajax, request-interception, response-mocking, javascript, web-server

## Member repositories
- jpillora/xhook (main) score 23

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:03:19.757054+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T07:04:16.851477+00:00, confidence not recorded.
  - readme: https://github.com/jpillora/xhook (fetched 2026-08-28T04:03:19.757054+00:00, sha 1ea5a206d314)
  - homepage: http://jpillora.com/xhook (fetched 2026-08-29T13:04:56.810674+00:00, sha 65fc932ec901)
- Data as of 2026-08-30T08:39:29.467469+00:00.
