Generic Fallback
<o-embed> is a universal embed tag. Any valid HTTP or HTTPS URL renders as an iframe — known providers get smart defaults (dimensions, permissions, aspect ratios), while unrecognized URLs fall back to a sandboxed iframe. This makes <o-embed> useful even for platforms that are not built-in providers.
How it works
When you pass a URL to <o-embed>:
- The component checks each registered provider’s
canParseUrl()method - If a provider matches, the URL is processed through the full pipeline (detect → extract → build → render) with provider-specific defaults
- If no provider matches, the component checks
isValidUrl()from@social-embed/lib - If the URL is a valid HTTP/HTTPS URL, it renders as a plain
<iframe>with security restrictions
Security attributes
Generic fallback iframes are sandboxed to limit their capabilities:
| Attribute | Value | Effect |
|---|---|---|
sandbox | allow-scripts allow-same-origin allow-popups | Allows JavaScript, same-origin access, and popups. Blocks forms, top-level navigation, and other capabilities. |
referrerpolicy | no-referrer | Prevents the embedded page from seeing which page embedded it. |
allowfullscreen | (not set) | Fullscreen is not enabled for generic embeds, unlike provider-specific ones. |
Library vs component behavior
@social-embed/lib and @social-embed/wc handle unrecognized URLs differently:
| Package | Unrecognized URL behavior |
|---|---|
@social-embed/lib | convertUrlToEmbedUrl() returns "". getProviderFromUrl() returns undefined. |
@social-embed/wc | Renders the URL as a sandboxed <iframe> with the security attributes above. |
This means the library is strict (no match = no output) while the component is permissive (no match = generic iframe). When building server-side validation, use the library’s behavior as the allowlist.
Limitations
Some sites prevent iframe embedding via HTTP headers:
X-Frame-Options: DENYorSAMEORIGIN— The browser will refuse to render the page in an iframeContent-Security-Policy: frame-ancestors 'none'— Same effect via CSP
The generic fallback cannot work around these restrictions. If an embedded site blocks framing, the iframe will show an error or blank page.
Examples
Basic
URL: https://netlify.com
<o-embed url="https://netlify.com/"></o-embed>Styled
<style> o-embed.full { --social-embed-iframe-height: 100%; --social-embed-iframe-width: 100%; width: 100%; height: 450px; }</style><o-embed url="https://en.wikipedia.org" class="full"></o-embed>