Automated OAuth 2.0 Token Lifecycle
Eliminates manual Basic auth encoding, credential fetching, and race conditions. Manages token rotation with a proactive 60-second safety buffer to prevent mid-flight 401s.
Stop hand-crafting PascalCase payloads, wrestling EAT timestamp drift, and managing OAuth tokens manually. @lumierelabs/daraja provides strict end-to-end types, client-side pre-flight validation, and native edge compatibility with zero dependencies.
The hard part of an M-Pesa integration is rarely calling the API endpoints. It's managing token lifecycles, timezone drift, callback parsing, validation, and multi-runtime compatibility.
Eliminates manual Basic auth encoding, credential fetching, and race conditions. Manages token rotation with a proactive 60-second safety buffer to prevent mid-flight 401s.
Automatically synchronizes timestamps to East Africa Time (UTC+3) and handles Base64 shortcode derivation, eliminating silent STK Push rejections from time drift.
Transforms nested Daraja callback arrays and string-encoded booleans into strongly typed domain models with discriminated union states.
Validates payload structures, callback URLs, and phone prefixes locally before network dispatch, cutting out sandbox trial-and-error.
Built strictly on native fetch and AbortController without Node.js core locks. Runs seamlessly on Vercel Edge, Cloudflare Workers, Deno, and Bun.
Protects server resources during upstream sandbox degradation with built-in AbortSignal support, preventing hanging requests.
Ships with zero third-party runtime dependencies, dual ESM/CJS outputs, and a single bundled declaration file for clean bundle hygiene.
One clean API across TypeScript, Next.js, Astro, and webhook infrastructure. Keep your code predictable and let the SDK handle the complexity.
The SDK handles the awkward parts of the M-Pesa API while keeping your application code predictable, typed, and easy to maintain.
Every interaction across the M-Pesa ecosystem is strongly typed, from STK Push, C2B, B2C Account Top Up, B2B Hakikisha, Dynamic QR, and Mobile Data Bundles to synchronous responses and asynchronous webhooks. Daraja quirks and legacy property names are represented accurately, giving you reliable autocomplete and compile-time guarantees.
Authentication is handled for you. Consumer credentials are exchanged automatically, access tokens are cached in memory according to their server-defined TTL, and a proactive 60-second refresh window prevents expiring credentials from turning into intermittent 401 responses.
Daraja-specific protocol details are normalized before a request leaves your server. The SDK handles EAT timestamp generation, Base64 password derivation, required parameter formatting, URL checks, payload constraints, and local validation so invalid requests fail early with useful errors.
Built entirely on standard Web APIs such as fetch and AbortController. Run the same SDK across Node.js, Vercel Edge, Cloudflare Workers, Deno, and Bun, with clean integration into Next.js, Remix, Astro, SvelteKit, Express, and Fastify.
Turn deeply nested Daraja callback payloads into usable typed data. Static parsing utilities unpack ResultParameter arrays, coerce string-encoded values, and expose discriminated success and failure states for predictable webhook processing.
No Axios, node-fetch, or heavyweight runtime wrappers. The package stays small, minimizes serverless cold starts, reduces supply-chain exposure, and ships ESM, CommonJS, and bundled TypeScript declarations for modern and legacy toolchains.
Stop maintaining payment boilerplate. Install the SDK, configure your Daraja credentials, and ship your integration in minutes.