How It Works
WCC let's you author standard custom elements and generate HTML from them using Light or Shadow DOM.
Step 1
Create a custom element
const template = document.createElement('template');
template.innerHTML = `
<style>
footer {
color: #efefef;
background-color: #192a27;
}
</style>
<footer>
<h4>My Blog © ${new Date().getFullYear()}</h4>
</footer>
`;
export default class Footer extends HTMLElement {
connectedCallback() {
if (!this.shadowRoot) {
this.attachShadow({ mode: 'open' });
this.shadowRoot.appendChild(template.content.cloneNode(true));
}
}
}
customElements.define('wcc-footer', Footer);
Step 2
Run it through WCC
import { renderToString } from 'wc-compiler';
const { html } = await renderToString(
new URL('./path/to/footer.js', import.meta.url)
);
Step 3
Get static HTML 🎉
<wcc-footer>
<template shadowrootmode="open">
<style>
footer {
color: #efefef;
background-color: #192a27;
}
</style>
<footer>
<h4>My Blog © 2026</h4>
</footer>
</template>
</wcc-footer>
Capabilities
WCC aims to cover a reasonable set of DOM APIs to help facilitate server-rendering of your Web Components.
Standard HTMLElement constructor
Also supports async rendering
Declarative Shadow DOM
Template element support (createElement)
Constructable Stylesheets shim
Attribute handling
Light DOM supported (aka. HTML Web Components)
Handled as a no-op
Features
In addition to server rendering, WCC also supports these additional features.
Custom JSX transform with the option to enable fine-grained reactivity compilation for interactive components.
Combined with JSX, leverage TypeScript to achieve type-safe HTML as you author, including intellisense.
Use WCC on its own, or integrate with your favorite framework, like Greenwood (opens in a new window), Astro (opens in a new window), or 11ty (opens in a new window).