Marko + Cloudflare Workers

See the the cloudflare sample project for a working example.


When using Marko with Cloudflare Workers you need to make sure that Marko is loaded with a worker export condition. Most bundlers support the ability to define export conditions.

After that point the will now return a worker compatible ReadableStream.

You can then simply respond with the returned stream.

import template from "./index.marko";

addEventListener("fetch", event => {

async function handleRequest(request) {
  return new Response(, {
    headers: {
      status: 200,
      headers: { "content-type": "text/html;charset=UTF-8" }

BYOB (Bring your own bundler)

For the large portion of Marko's API a bundler is required. The example code above assumes that Marko templates can be loaded in your environment. Marko supports a number of bundlers, take a look through our supported bundlers and pick what works best for you.



Helpful? You can thank these awesome people! You can also edit this doc if you see any issues or want to improve it.

Chat in Marko's Discord Server