wpcom-xhr-request is a lightweight browser library for making authenticated REST API requests to WordPress.com using XMLHttpRequest and CORS. Version 1.3.1 is the latest stable release. It handles OAuth 1.0a authentication and token management, providing a simpler interface than raw XMLHttpRequest or fetch with custom auth headers. Unlike the Node.js counterpart wpcom.js, this package is specifically designed for client-side use in browsers. It has low release cadence, with occasional maintenance updates. Key differentiators: automatic OAuth signing, cookie-based token storage, and integration with WordPress.com's API endpoints.
npm install wpcom-xhr-requestNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic authenticated GET request to the WordPress.com API /me endpoint with callback handling.
Consider using wpcom-fetch or native fetch with a library like wpcom-oauth-utils.
Obtain an access token via the WordPress.com OAuth flow before making requests.
If using older versions, update imports: `import wpcomXhrRequest from 'wpcom-xhr-request'` now works directly.
Ensure the WordPress.com application is configured with the correct allowed origins.
Use the apiVersion parameter to specify the version, or switch to a newer library.
Use `import wpcomXhrRequest from 'wpcom-xhr-request'` instead of `import { wpcomXhrRequest } from 'wpcom-xhr-request'`.Add your app's origin to the 'Allowed origins' list in WordPress.com Developer Console.
Pass a valid access token via the accessToken option in the request object.
No dependency data recorded yet.