CGChristoph Griehl
Resume
WorkExpertiseWritingAboutContact
← All writing
Technical · Web components · Web Development

Building a Production Web Component Library

Lessons from a LitElement component library used across dozens of apps — API design, cross-browser testing, and docs.

CG
Christoph Griehl
Senior Full-Stack Engineer
Apr 16, 20232 min read
logo of the web component standard
logo of the web component standard

I spent a long stretch building and maintaining a LitElement web component library consumed by dozens of applications. Shipping that many components — across themes, browsers, and teams I didn’t control — taught me where web components shine and where they quietly cost you. This is what I’d tell anyone about to start their own.

Why web components

Web components are a set of platform APIs for building reusable custom elements with their behavior and styling encapsulated. The payoff is a design system you can share across applications regardless of their framework, with an API grounded in web standards rather than any one library’s lifecycle. Ionic is the canonical example of how far that approach scales.

The parts that are genuinely hard

The model has real surface area: lifecycle callbacks, the shadow DOM, the interplay of properties and attributes, form participation, and CSS custom properties as your theming seam. Do not hand-write all of that — use a framework like LitElement (class syntax) or Stencil (JSX) and let it absorb the boilerplate.

The harder, less glamorous work is testing. Every supported browser has its own take on HTML, CSS, and JavaScript, and a component library has to behave the same across all of them. That cross-browser guarantee is most of what separates a demo from something other teams can depend on.

Designing the API is the real work

A component’s public API is a contract, and once dozens of apps depend on it, breaking it is expensive. A few things made that sustainable:

  • An automated release pipeline with clear semantic versioning, so consumers know exactly what an upgrade means.
  • Documentation with interactive, runnable examples — the fastest way for consumers to understand a component is to change its props and watch it react.
  • A real support channel from day one, because questions are inevitable and a library without support erodes trust fast.

A component library lives or dies by its API and its documentation, not by how many components it ships.

For showcasing components I used Storybook, and I can’t recommend it without reservation — it was often buggy and its API got in the way more than it helped.

What carries over

Web components are a powerful, framework-agnostic way to build reusable UI, but the leverage comes from treating the library as a product: a stable API, excellent docs, and a testing story that survives four browsers. Testing and monitoring components in particular deserve their own article — they are harder than ordinary UI testing, and worth getting right.

Web componentsLit ElementLibraryUXUI
CG
Christoph Griehl

Senior full-stack engineer in Germany, working across AI/RAG systems, geospatial software, document intelligence, and data-heavy web platforms.

Keep reading
Mar 20, 2023 · Project

Predium: Engineering ESG Real Estate Software

Read article →
Jan 8, 2022 · Project

Shipping a Fast Website for a Family Restaurant

Read article →