Stencil and Lit are direct choices for authoring reusable custom elements with different toolchains. Svelte provides a compiled component model and can also target custom elements; evaluate whether the deliverable is a portable element library or a Svelte application.
Start with the consumer. A custom-element library consumed by several frameworks has different packaging needs from an application built around Svelte components.
@stencil/core supplies a compiler and development toolchain for Web Components written with TypeScript, JSX and CSS. Its stencil command and distribution options belong to the authoring project. TSX-like syntax does not mean consumers receive React components. Framework wrappers and loading integrations have their own event, property and packaging conventions.
Lit supplies reactive properties, a component base and declarative templates for custom elements. It is a library-oriented route rather than Stencil's complete compiler workflow. The project still defines public properties, attributes, events and styles and chooses its build and distribution arrangement.
Both require thoughtful component contracts. Shadow DOM, slots and custom events affect host integration; standards alone do not make every form interaction or framework wrapper automatic. Core installation does not supply every server-rendering or hydration integration.
Svelte uses a compiler-controlled component syntax with reactivity such as $state, $derived and $props. These are not React hooks or Lit property declarations. The package also includes runtime and server/client interfaces; compilation does not mean interactive components have no runtime behavior.
Svelte can compile components for custom-element use when deliberately configured. That output and an ordinary Svelte component have different consumer interfaces. Application routing and deployment conventions come from an application layer such as SvelteKit, not from assuming every compiler package is a complete application framework.
Build one representative component with properties, events, styling and an actual host application. Compare initialization and cleanup, complex values, forms and the intended server-rendering path. Choose Stencil or Lit for their respective custom-element authoring workflows, and Svelte when its component model or configured element output fits the deliverable. A migration changes state, templates, lifecycle and packaging rather than only the build command.
Choose its compiled component model for a Svelte UI, or deliberately configure custom-element output when that distribution target is required.
Choose a reactive element base and declarative templates for custom elements when a library-oriented authoring model fits the required build setup.
Choose its TypeScript/JSX compiler and distribution tooling for a reusable custom-element library when that authoring workflow fits the team.
Svelte is a new way to build web applications. It's a compiler that takes your declarative components and converts them into efficient JavaScript that surgically updates the DOM.
Learn more at the Svelte website, or stop by the Discord chatroom.
You can play around with Svelte in the tutorial, examples, and REPL.
When you're ready to build a full-fledge application, we recommend using SvelteKit:
npx sv create my-app
cd my-app
npm install
npm run dev
See the SvelteKit documentation to learn more.
The Changelog for this package is available on GitHub.
Svelte is an MIT-licensed open source project with its ongoing development made possible entirely by fantastic volunteers. If you'd like to support their efforts, please consider:
Funds donated via Open Collective will be used for compensating expenses related to Svelte's development.