Lorixen.
EN

Web components and SEO: make shadow DOM content indexable

Short answer: Google says it supports web components: when it renders a page, it flattens shadow DOM and light DOM content together, and it can index what appears in the rendered HTML. The risk is content that only appears after interaction, loads too late, or never reaches the rendered page at all. Put important text in the light DOM and pass it into components through slots, consider declarative shadow DOM or server rendering for key components, and check the rendered HTML with Google's URL Inspection tool.

Why web components raise SEO questions

Web components let developers build reusable custom elements, such as <product-card> or <booking-widget>, that work in any page. Many design systems, site builders and third-party widgets now ship as web components. A core feature is the shadow DOM. MDN explains that encapsulation is central to custom elements, and the shadow DOM provides it: a separate tree, starting at a shadow root, attached to an element and hidden from the page's normal styles and scripts.

That hiding is great for avoiding style clashes. It also makes marketers and SEO consultants nervous: if the product description lives inside a shadow root, can search engines see it?

What Google says

Google's JavaScript SEO basics guide addresses web components directly. It states that Google supports web components, and that when Google renders a page, it flattens the shadow DOM and light DOM content. Google can only see content that's visible in the rendered HTML, so it advises checking with the Rich Results Test or the URL Inspection tool and looking at the rendered HTML. If content isn't in the rendered HTML, Google won't be able to index it.

So shadow DOM itself isn't the problem. The usual problems are the same ones any JavaScript-heavy page has.

Where content goes missing

  • Content loaded only on interaction. Tabs, accordions or "load more" buttons that fetch text only when clicked. If it isn't in the rendered page without a click, it may not be indexed.
  • Late or failing data fetches. A component that calls an API for product text after the page loads may not finish while the page is rendered, or may fail for crawlers if the API blocks them.
  • Components that never render. Script errors, blocked script files in robots.txt, or a missing component definition leave an empty tag.
  • Text inside attributes only. A component that receives its description as an attribute and renders it in a way that doesn't end up in the flattened output.
  • Links built without real anchors. Navigation inside components that uses click handlers instead of <a href> elements can't be followed.

Patterns that keep content visible

Use slots for important content. Put headings, descriptions and links in the light DOM, as children of the custom element, and let the component display them through a <slot>. MDN describes how slotted elements stay in the normal document while being shown inside the component. That keeps key content in the page's HTML from the start, even before the component's script runs.

Use declarative shadow DOM for server-rendered components. The <template> element's shadowrootmode attribute, documented on MDN as a declarative version of attachShadow(), lets the server send a component's shadow content as HTML. The browser builds the shadow root while parsing, without waiting for JavaScript. Many component frameworks can render this way.

Render important content on the server. For product pages, articles and service pages, sending meaningful HTML in the initial response is the most dependable approach, whatever component technology you use.

Keep links as real links. Inside or outside components, use <a href="..."> for navigation you want crawled.

How to check your pages

  1. Open the URL Inspection tool in Search Console for a representative page and run a live test. View the rendered HTML and search it for a sentence from your component's content.
  2. Use the Rich Results Test on pages where you can't use Search Console, and inspect the rendered HTML in the same way.
  3. Check the page with JavaScript off in your browser to see what's in the initial HTML. Content in slots or declarative shadow DOM should still be present.
  4. Watch the browser console for errors that stop components rendering.
  5. Search Google for an exact sentence from a component-only section, a few weeks after publishing, to confirm it's indexed.

A quick checklist for developers

Before a component-based page goes live, confirm that:

  • The page's main heading and introductory text are in the initial HTML.
  • Every important link is an <a> element with an href.
  • Component scripts aren't blocked by robots.txt.
  • Content doesn't depend on a click, scroll or hover to load.
  • The rendered HTML in URL Inspection contains the same text a visitor sees.

For third-party widgets

Review widgets, booking embeds and chat tools often arrive as web components or iframes. Treat their content as a bonus rather than relying on it for your rankings. If text like reviews or opening hours matters for search, publish it in your own HTML as well, where appropriate.

A worked example

Take a hypothetical Newcastle (NSW) boat-hire company whose new site used a design-system <service-card> component for each hire option. The descriptions were passed as attributes and fetched prices loaded after a click on "Show details". In URL Inspection, the rendered HTML showed the card titles but not the descriptions. The developer changed the component to display descriptions and links through slots, rendered prices on the server, and kept the click-to-expand only for the booking calendar. A re-test showed the full text in the rendered HTML.

FAQ

Should I avoid shadow DOM for SEO?

No. Google renders and flattens it. Focus on making sure content appears without interaction and links are real.

What about other search engines?

Rendering support varies. Server-rendered or slotted content is the safest choice for all of them.

Does closed shadow DOM hide content from Google?

Google's guidance speaks of flattening shadow DOM content in general; test your own pages' rendered HTML to be sure.

Are iframes treated the same way?

No. Iframe content belongs to another page and is handled differently from shadow DOM.

If your new component-based site isn't showing up in search the way you expected, tell us how it's built.

Sources

WhatsAppBook a call