The Problem With Web Components and SEO
Web components have been around for years, but they’ve always had one glaring weakness: server-side rendering. Custom elements need JavaScript to work, and without it, search engines and social media crawlers see nothing but empty tags. For a Python shop running FastAPI or Django, the usual answer was “add a Node.js sidecar for SSR.” Nobody liked that answer.
Lit 3.0 changed the math. Its SSR package now runs in any JavaScript environment that supports the standard DOM APIs — and critically, it doesn’t require a full Node.js server. That opens the door to running Lit SSR from Python via a subprocess or embedded runtime.
How It Works in Practice
The architecture is straightforward. Your Lit components live in a separate directory, compiled ahead of time. When a request hits your Python backend, you shell out to a small Node.js script that renders the component to a string, returns it via stdout, and your Python app stitches it into the template.
It sounds fragile, but with proper caching and a process pool, it’s surprisingly fast. Sub-millisecond overhead for cached renders, and around 20 to 30 milliseconds for cold renders on modest hardware.
Where This Actually Matters
The real win isn’t just SEO. It’s the development experience. A team that builds their UI as web components can share them across a Django admin panel, a FastAPI dashboard, and a static marketing site — all rendered server-side from the same Python backend.
Chris Ferdinandi at Go Make Things has been tracking this pattern. At An Event Apart earlier this year, he showed a demo where a single set of Lit components powered both a Flask server-rendered page and a SPA, with hydration happening only when the user interacted with dynamic parts.
The Catch
Lit SSR from Python isn’t seamless yet. You’re managing two runtimes, two package managers, and two deployment concerns. The Node.js bridge adds a dependency that fails in environments where you can’t install Node (some serverless platforms). And debugging across the Python-to-JS boundary is painful when things go wrong.
The ecosystem is responding. Projects like python-lit-ssr on PyPI wrap the Node.js bridge in a clean API. Vercel and Cloudflare both now support Python workers with WASM-based JavaScript runtimes, which could eliminate the subprocess hack entirely.
Should You Adopt This?
If your team already uses web components and Python, Lit SSR from Python is a pragmatic choice for 2026. If you’re starting fresh, weigh it against HTMX (simpler, no JS build step) or a full Next.js/Remix approach (better ecosystem, but you’re leaving Python). The hybrid approach works best when you’re already committed to web components and just need SSR to fill the gap.
The bottom line: Python backends no longer have to choose between SEO-friendly pages and a component-based UI. It’s not always pretty, but it works.
Discussion
Leave a comment
No comments yet
Be the first to start the conversation.