Web Components - Write Once, Use in React, Vue, and Angular - SvGrid blog illustration

Web Components - Write Once, Use in React, Vue, and Angular

How custom elements let a single UI component run across frameworks, the interop gotchas to know, and when native beats cross-framework.

Most teams are not on a single framework. A company has a React app, an Angular admin tool a team inherited, a Vue marketing site, and a couple of plain-HTML internal pages. Maintaining the same data grid four times is nobody's idea of fun. Web Components - custom elements built on web standards - are the standard answer to "write the component once, use it everywhere."

What a Web Component is

A Web Component is a custom HTML element backed by browser-native APIs: the Custom Elements registry, Shadow DOM for style encapsulation, and HTML templates. Because it is part of the platform, any framework that renders HTML can render it.

<sv-grid></sv-grid>
<script type="module">
  const grid = document.querySelector('sv-grid')
  grid.data = rows
  grid.columns = columns
</script>

That same tag works inside a React component, a Vue template, an Angular view, or a static page.

The interop you need to know

Cross-framework freedom comes with a few sharp edges. They are all manageable once you know them:

None of these are dealbreakers - they are just the contract of crossing the framework boundary.

When cross-framework is the right call

Reach for Web Components when:

This is exactly why the team behind SvGrid also ships Smart UI as web components on htmlelements.com - one grid that drops into React, Angular, Vue, or plain HTML.

When native beats cross-framework

Web Components are a compromise: to work everywhere, they cannot assume any one framework's reactivity, so they re-implement state management internally. Inside a single framework, a native component is usually smaller and more ergonomic, because it speaks the framework's own model directly.

That is the case for SvGrid itself: a Svelte app gets a grid written natively on Svelte 5 runes, with no interop layer. A mixed-framework shop gets the web-components route. Same engineering team, two delivery models, chosen by your architecture rather than forced by the tool.

A practical rule of thumb

Frequently asked questions

Can one Web Component really work in React, Vue, and Angular?

Yes. Custom elements are part of the browser platform, so any framework that renders HTML can use them. You set rich data as DOM properties and listen for custom events, with minor per-framework binding details.

Should I use a Web Component or a native framework component?

Use a native component when you are committed to one framework - it is smaller and more ergonomic. Use a Web Component when you ship across multiple frameworks or need to survive a framework migration.