Moesif Cloudflare SDK

This SDK is for integration Moesif with Cloudflare Workers using the new ES Module Model.

This npm package only support node 18 and 20.

Important Note about Legacy Service Worker Model

If you are using Cloudflare’s Service Workers API instead of the new EsModule, please follow the legacy instruction here


in your wrangler created project.

npm install moesif-cloudflare

In your code

import moesifMiddleware from 'moesif-cloudflare';

const options = {
  applicationId: 'YOUR MOESIF Application ID',

// your original fetch handler.
async function originalFetchHandler(request, _env, context) {
  // your code.

// this create a new fetch that is wrapped by moesifMiddleware
const wrappedFetchHandler = moesifMiddleware(originalFetch, options);

// export the fetch handler.
export default {
  fetch: wrappedFetchHandler


See full list of options for moesifMiddleware in prepareOptions.mjs, see DEFAULT_OPTIONS;


The example-project folder contains an example generated via npm create cloudflare@latest as in the Cloudflare get started guide