Stencil compiles TypeScript and JSX into web components you can use in React, Angular, Vue, or plain HTML. It targets design systems and shared component libraries.
Overview
Stencil is a compiler for building web components with TypeScript and JSX, created by the Ionic team. You author decorated component classes and Stencil emits standard custom elements that run across major front-end frameworks or without a framework.
Components can use shadow DOM, slots, and scoped styles. Stencil ships with a small runtime, an asynchronous rendering pipeline, and presets for local development including a hot-reloading dev server. Output can be tuned for tree shaking and lazy loading.
The toolchain includes unit testing support, code generation for new components, TypeScript source maps, and documentation generation from JSDoc near the source. Integrations are documented for using custom elements inside Angular, React, and Vue codebases.
Stencil is aimed at enterprise-style component systems: one framework-agnostic codebase can be packaged for React, Angular, Vue, and traditional web apps. It can also serve as a frontend build approach where web components are the portable output format.
Key features
- Web Components output from TypeScript
- JSX component authoring
- Shadow DOM and slots
- React, Angular, and Vue integration paths
- Built-in dev server with hot reload
- JSDoc-driven doc generation
- Unit testing built in
- Component and style code generation
Use cases
- Publishing a shared design system
- Cross-framework component libraries
- Standards-based UI for multiple apps
- Migrating away from framework-specific widgets
- Documented component APIs for product teams