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 &copy; ${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 &copy; 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.

constructor

Standard HTMLElement constructor

connectedCallback

Also supports async rendering

attachShadow

Declarative Shadow DOM

< template >

Template element support (createElement)

CSSStyleSheet

Constructable Stylesheets shim

[get|set|has]Attribute

Attribute handling

innerHTML

Light DOM supported (aka. HTML Web Components)

addEventListener

Handled as a no-op

Features

In addition to server rendering, WCC also supports these additional features.

JSX

Custom JSX transform with the option to enable fine-grained reactivity compilation for interactive components.

TypeScript

Combined with JSX, leverage TypeScript to achieve type-safe HTML as you author, including intellisense.

Pluggable

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).