better-video-embeds
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Better Video Embeds

Pass in a url that should be a video embed link...and get back a properly formated embed link. (Works for YouTube, Vimeo, Wistia and more!)

Blazing Fast Blazing Fast Blazing Fast

npm i better-file-downloader yarn add better-file-downloader

View on NPM

For example:

https://www.youtube.com/watch?v=O9ydMYA8dmw becomes https://www.youtube.com/embed/O9ydMYA8dmw

The api currently supports parsing out the following embed strings:

  • YouTube
  • Vimeo
  • Matterport
  • Daily motion
  • Wistia

The library works with react and is fairly lightweight in size.

You'll be converting your users dirty video links scripts into embed links that you can iframe in no time!

Examples

import getEmbedUrl from 'better-video-embeds';
const getEmbedUrl = require('better-video-embeds');

const embedLink = getEmbedUrl('https://www.youtube.com/watch?v=O9ydMYA8dmw');
import getEmbedUrl from 'better-video-embeds';
const getEmbedUrl = require('better-video-embeds');

const embedLink = getEmbedUrl('https://www.youtube.com/watch?v=O9ydMYA8dmw', {
  includeModestYouTubeBranding: true,
});
import React, { useState } from 'react';
import getEmbedUrl from 'better-video-embeds';

export default function example() {
  const [videoLink, setVideoLink] = useState('');

  const submit = event => {
    event.preventDefault();
    const embedLink = getEmbedUrl(videoLink);
    console.log(embedLink);
  };

  return (
    <form onSubmit={submit}>
      <input
        value={videoLink}
        type="text"
        onChange={event => setVideoLink(event.target.value)}
      />
      <button type="submit">Save!</button>
    </form>
  );
}

Package Sidebar

Install

npm i better-video-embeds

Weekly Downloads

183

Version

1.0.1

License

MIT

Unpacked Size

15.8 kB

Total Files

10

Last publish

Collaborators

  • tylerzey