Skip to main content

Installation

info

Just want the lib functions and patterns? See @social-embed/lib.

Install#

<o-embed> is distributed on npm, so you can install it locally or use it via npm CDNs like unpkg.com.

Local Installation#

NPM:

npm i @social-embed/wc

yarn:

yarn add @social-embed/wc

CDN#

npm CDNs like unpkg.com can directly serve files that have been published to npm. This works great for standard JavaScript modules that the browser can load natively.

For this element to work from unpkg.com specifically, you need to include the ?module query parameter, which tells unpkg.com to rewrite "bare" module specificers to full URLs.

HTML#

<script type="module" src="https://unpkg.com/@social-embed/wc?module"></script>
<o-embed url="https://youtu.be/Bd8_vO5zrjo" allowfullscreen></o-embed>
<o-embed
url="https://www.youtube.com/watch?v=NB5hH3ksvKE"
allowfullscreen
></o-embed>

Try on codepen, check "Playground" in the top menu for more!

JavaScript#

import {OEmbedElement} from 'https://unpkg.com/@social-embed/wc?module';