Overview
Cloudflare introduces a new Worker template for Vertical Microfrontends (VMFE) that allows mapping multiple independent Cloudflare Workers to a single domain, enabling teams to develop and deploy frontend applications independently by sub-path. The article covers how to use CSS View Transitions, Speculation Rules API for preloading, service bindings for request routing, and HTMLRewriter for path rewriting to create a seamless unified user experience from separate codebases.
What You'll Learn
How to split a large frontend application into independently deployable vertical microfrontends using Cloudflare Workers
How to use CSS View Transitions to make separate Worker-hosted pages feel like a single-page application
How to configure Cloudflare Worker service bindings and route definitions for sub-path-based request routing
Why vertical microfrontends improve team autonomy by eliminating cross-team deployment dependencies
How to use HTMLRewriter to fix asset paths when reverse-proxying microfrontend responses through a Router Worker
Prerequisites & Requirements
- Understanding of frontend web development concepts including SPA vs MPA architectures
- Familiarity with Cloudflare Workers and the Wrangler CLI configuration
- Basic understanding of HTML, CSS, and JavaScript including DOM concepts
- Understanding of reverse proxy patterns and URL path routing(optional)
- Experience with at least one frontend framework (React, Vue, Svelte)(optional)
Key Questions Answered
What is the difference between vertical and horizontal microfrontends?
How do Cloudflare Workers route requests to different microfrontend applications?
How do CSS View Transitions make separate microfrontends feel like one application?
What are Cloudflare Worker service bindings and how do they enable microfrontends?
Why does the Router Worker strip the path prefix before forwarding requests?
How does HTMLRewriter fix broken asset paths in vertical microfrontends?
How does the Speculation Rules API improve microfrontend navigation performance?
Does Cloudflare use vertical microfrontends in their own dashboard?
Technologies & Tools
Some links below are affiliate links. We may earn a commission if you make a purchase.
Key Actionable Insights
1Use CSS View Transitions with view-transition-name to make shared UI elements (like navigation bars) persist across microfrontend boundaries. Just a few lines of CSS — defining animation-duration, timing-function, and view-transition-name on shared elements — eliminates the jarring white-screen flash between page navigations, making separate Workers feel unified.This is most critical when vertical slices exist within a single experience (e.g., multiple product pages in a dashboard) where users would not expect to see a page reload. For clearly separate sections like marketing vs. docs, slight load transitions are acceptable.
2Define your ROUTES configuration with the smoothTransitions and preload flags to automatically inject View Transition CSS and Speculation Rules into responses via HTMLRewriter, avoiding manual code changes in each microfrontend project. Setting smoothTransitions to true at the root level and preload to true on individual routes automates the unified experience.This zero-config approach means individual microfrontend teams don't need to coordinate on shared CSS or preloading logic — the Router Worker handles it transparently.
3Design each microfrontend Worker to function independently at its own URL without depending on the Router Worker's path prefix. The Router Worker automatically strips the path prefix before forwarding, so the downstream Worker should handle requests as if it's at the root path. This preserves the ability to develop and test each service in isolation.This architectural decision simplifies local development and testing — each team can run and deploy their Worker independently, and it will work both standalone and behind the Router Worker.
4Use Cloudflare Worker service bindings instead of public HTTP calls for communication between the Router Worker and microfrontend Workers. Service bindings enable internal Worker-to-Worker communication without traversing the public internet, reducing latency and keeping the stitching mechanism private.Service bindings are configured in the wrangler.json file by defining a binding name and the target service. This is the core mechanism that enables path-based routing under a single domain.
5Account for HTML asset path rewriting when architecting your microfrontend responses. Since individual Workers return HTML with paths relative to their own root, the Router Worker must use HTMLRewriter to prepend the path prefix to absolute asset references in the response before returning it to the browser.Without this rewriting step, images, scripts, and stylesheets will fail to load when the microfrontend is accessed through the Router Worker's sub-path, because the browser resolves relative URLs against the wrong base path.