TLDR: mirco-frontends potentially offer a http based server-interoperable component “over the wire” expierence for building siloed server-rendered components. This post is a response to Cloudflare Workers and micro-frontends: made for one another.
I’ve been struggling over the last couple months with the increasing number of meta-frameworks, truly trying to understand them, why they exist, what they do and can’t do. A list of some of the ones I’ve looked into are Astro, Qwik, Deno Fresh, LiveViewJS and Next.js Layouts (currently unreleased).
My goal has been to find a way to bundle a component ui, with server stuff like database or 3rd party api calls, and have this be something that other people could use as well. Quite frankly my goal has to create an open-source calendly. Don’t get me wrong for non-developers, but us dev’s should have a customizable open solution. The current model for open source things like this is to ship a whole server and run a copy yourself, but what happens if you want to include the component on your portfolio or blog? The only thing really available may be an iframe, which has a whole suite of problems.
I thought that meta-frameworks were going to save me from this dilemma. How can I write component code for the client + server, and use it on multiple sites with ease?
A couple of days ago I stumbled upon this video on something called “micro-frontends”, pretty curious I watched the talk by Adam.
This video, while very informative about the ideas and philosophy of micro-frontends does not go into the technical details of how to implement a micro-frontend.
The general gist is a micro-frontend borrows from the idea of micro-services in that instead of a service as the shippable item, it’s a component.
Coincidentally within days of watching the video this was released:
Hours early I had expressed interest in the same exact idea, so I think the idea overall is in the zeitgeist, there’s a need to silo this type of code in a way to make it portable and easier to work on.
I’ve been really interested in server components for over a year now since the react team first mentioned them, and I’m very interested what the Next.js shows the world in 4 days when they release the Layouts & Server Components. Ultimately I’m really interested in code that looks like this:
Server components and micro-frontends are not the same technically but kid of achieve similar goals, join pieces of the client + server code to generate a single component (ideally with front-end interactivity).
I think the biggest pitfall of using micro-frontends is the orchestration piece, when you start to have a bunch of these servers running all over the place it’s a headache to maintain.
I look at the cloudflare example as a way to implement a iframe on the server, something like this:
However the cloudflare team didn’t implement it like this because then it wouldn’t be able to work locally, so get around this they use
.env vars and tie the domains in to named keys, also
ServerIframe isn’t a great name.
<FragmentPlaceholder name="body" />
I think it’s pretty cool you can still access each fragment individually:
You can also pass query parameters to fragments like this: https://cloud-gallery-gallery.web-experiments.workers.dev/?tag=dark
I have less faith that there will be one framework that solves everything and gives the developer complete control over how the code gets compiled, how the site gets rendered, how data is maintained, how the dom gets updated, how the server works, how routing works, all of it. It’s too much to ask for one meta-framework to figure out everything. Even
Some more resources: