Embedrax is an embed package for React, Vue, Angular, and Svelte which can embed from platforms like Facebook, Instagram, TikTok, YouTube/Shorts, Twitter/X, Vimeo and Dailymotion.
Frameworks / Libraries | Tested versions |
---|---|
18 & above | |
3 & above | |
16 & above | |
3 & above |
Major Changes: v1.0.0
Minor Changes:
v1.2.0
v1.1.0
Patch Changes:
v1.1.2
v1.1.1
v1.0.3
v1.0.2
v1.0.1
index.css
or app.css
are not conflict, if you notice your css videos are not working properly.Try to clear your existing css like index.css
or app.css
affected in React, Vue, Svelte and Angular.
See if it's working.
Then RESTORE the original index.css
or app.css
codes.
To install the Embedrax, you can use the following npm command:
npm install embedrax
Value | Width and Height in the Component file | Width only from the classname CSS file |
---|---|---|
1280x720 | width: 1280, height: 720, | .embed-youtube-one-clip { max-width: 1280px;} |
854x480 | width: 854, height: 480, | .embed-youtube-one-clip { max-width: 854px;} |
640x360 | width: 640, height: 360, | .embed-youtube-one-clip { max-width: 640px;} |
426x240 | width: 426, height: 240, | .embed-youtube-one-clip { max-width: 426px;} |
256x144 | width: 256, height: 144, | .embed-youtube-one-clip { max-width: 256px;} |
Use Google chrome as much as possible to load more videos properly.
Reminder:
import { useEffect } from 'react';
import { embed } from 'embedrax';
export const ExampleComponent = () => {
useEffect(() => {
embed([
{
width: 854,
height: 480,
autoplay: true,
fullscreen: false,
controls: true,
videoUrl: 'https://www.youtube.com/watch?v=oEXFMGK7IC0',
videoClass: 'embed-youtube-one-clip'
}
])
});
return (
<>
<div className="embed-youtube-one-clip"></div>
</>
);
};
or
import { useEffect } from 'react';
import { embed } from 'embedrax';
const ExampleComponent = () => {
useEffect(() => {
embed([
{
width: 854,
height: 480,
autoplay: true,
fullscreen: false,
controls: true,
videoUrl: 'https://www.youtube.com/watch?v=oEXFMGK7IC0',
videoClass: 'embed-youtube-one-clip'
}
])
});
return (
<>
<div className="embed-youtube-one-clip"></div>
</>
);
};
export default ExampleComponent
import { useEffect } from 'react';
import { embed } from 'embedrax';
interface VideoConfig {
width?: number;
height?: number;
autoplay?: boolean;
fullscreen?: boolean;
controls?: boolean;
videoUrl: string;
videoClass: string;
}
export const ExampleComponent: React.FC = () => {
const videos: VideoConfig[] = [
{
videoUrl: '',
videoClass: 'embed-tiktok',
},
{
width: 854,
height: 480,
autoplay: false,
fullscreen: true,
controls: true,
videoUrl: 'https://www.youtube.com/watch?v=oEXFMGK7IC0',
videoClass: 'embed-youtube-one-clip'
},
];
useEffect(() => {
embed(videos);
});
return (
<>
<div className="embed-tiktok"></div>
<div className="embed-youtube-one-clip"></div>
</>
);
};
<template>
<div>
<div class="embed-youtube-one-clip"></div>
</div>
</template>
<script>
import { onMounted } from 'vue';
import { embed } from 'embedrax';
export default {
name: 'ExampleComponent',
setup() {
onMounted(() => {
embed([
{
width: 854,
height: 480,
autoplay: true,
fullscreen: false,
controls: true,
videoUrl: 'https://www.youtube.com/watch?v=oEXFMGK7IC0',
videoClass: 'embed-youtube-one-clip'
}
])
});
return {};
},
};
</script>
<script lang="ts">
import { onMount } from 'svelte';
import { embed } from 'embedrax';
interface VideoConfig {
width?: number;
height?: number;
autoplay?: boolean;
fullscreen?: boolean;
controls?: boolean;
videoUrl: string;
videoClass: string;
}
const videos: VideoConfig[] = [
{
videoUrl: '',
videoClass: 'embed-tiktok'
},
{
width: 854,
height: 480,
autoplay: false,
fullscreen: true,
controls: true,
videoUrl: 'https://www.youtube.com/watch?v=oEXFMGK7IC0',
videoClass: 'embed-youtube-one-clip'
},
];
onMount(() => {
embed(videos);
});
</script>
<div>
<div class="embed-tiktok"></div>
<div class="embed-youtube-one-clip"></div>
</div>
<script>
import { onMount } from 'svelte';
import { embed } from 'embedrax';
onMount(() => {
embed([
{
width: 854,
height: 480,
autoplay: true,
fullscreen: false,
controls: true,
videoUrl: 'https://www.youtube.com/watch?v=oEXFMGK7IC0',
videoClass: 'embed-youtube-one-clip'
}
]);
});
</script>
<div>
<div class="embed-youtube-one-clip"></div>
</div>
<template>
<div>
<div class="embed-tiktok"></div>
<div class="embed-youtube-one-clip"></div>
</div>
</template>
<script setup lang="ts">
import { onMounted } from 'vue';
import { embed } from 'embedrax';
const videos = <VideoConfig[]>([
{
videoUrl: '',
videoClass: 'embed-tiktok'
},
{
width: 854,
height: 480,
autoplay: false,
fullscreen: true,
controls: true,
videoUrl: 'https://www.youtube.com/watch?v=oEXFMGK7IC0',
videoClass: 'embed-youtube-one-clip'
},
]);
onMounted(() => {
embed(videos);
});
interface VideoConfig {
width?: number;
height?: number;
autoplay?: boolean;
fullscreen?: boolean;
controls?: boolean;
videoUrl: string;
videoClass: string;
}
</script>
example.component.ts
import { Component, AfterViewInit } from '@angular/core';
import { embed } from 'embedrax';
@Component({
selector: 'app-example',
template: `
<div class="embed-youtube-one-clip"></div>
`,
styleUrls: ['./example.component.css'],
})
export class ExampleComponent implements AfterViewInit {
ngAfterViewInit() {
embed([
{
width: 854,
height: 480,
autoplay: true,
fullscreen: false,
controls: true,
videoUrl: 'https://www.youtube.com/watch?v=oEXFMGK7IC0',
videoClass: 'embed-youtube-one-clip'
}
]);
}
}
For Angular css:
::ng-deep .embed-youtube-one-clip {
display: flex;
justify-content: center; /* Center horizontally */
align-items: center; /* Center vertically */
border: 2px solid orange;
width: 100%;
max-width: 854px;
margin: auto; /* Center the entire container horizontally */
}
Make sure your default index.css
or app.css
are not conflict, if you notice your css videos are not working properly.
Try to clear your existing css like index.css
or app.css
affected in React, Vue, Svelte and Angular.
See if it's working.
Then RESTORE the original index.css
or app.css
codes.
You can add your own css set-up:
You may apply to app.css or index.css or any css file.
This is sample only, you can rename, recreate, and do something:
.embed-youtube-one-clip {
display: flex;
justify-content: center;
align-items: center;
border: 2px solid orange;
width: 100%;
max-width: 854px;
margin: auto;
}
For more css embed video styles:
/* app.css or index.css or any */
.embed-tiktok {
display: inline-flex;
position: relative;
width: 100%;
max-width: 370px;
max-height: 560;
float: left;
}
.embed-twitter {
display: inline-flex;
position: relative;
width: 100%;
max-width: 300px;
float: left;
}
.embed-youtube {
position: relative;
display: inline-flex;
width: 100%;
max-width: 640px;
max-height: 360; /* Allow the height to adjust proportionally */
float: left;
}
.embed-facebook {
display: inline-flex;
position: relative;
width: 100%;
max-width: 318px;
max-height: auto; /* Allow the height to adjust proportionally */
float: left;
}
.embed-facebook2 {
display: inline-flex;
position: relative;
width: 100%;
max-width: 318px;
max-height: auto; /* Allow the height to adjust proportionally */
float: left;
}
.embed-vimeo {
display: inline-flex;
/* You can assign any css properties */
}
.embed-dailymotion {
display: inline-flex;
/* You can assign any css properties */
}
CSS for Angular:
/* example/component.css */
::ng-deep .embed-tiktok {
display: inline-flex;
position: relative;
width: 100%;
max-width: 370px;
max-height: 560;
float: left;
}
::ng-deep .embed-twitter {
display: inline-flex;
position: relative;
width: 100%;
max-width: 300px;
float: left;
}
::ng-deep .embed-youtube {
position: relative;
display: inline-flex;
width: 100%;
max-width: 640px;
max-height: 360; /* Allow the height to adjust proportionally */
float: left;
}
::ng-deep .embed-facebook {
display: inline-flex;
position: relative;
width: 100%;
max-width: 318px;
max-height: auto; /* Allow the height to adjust proportionally */
float: left;
}
::ng-deep .embed-facebook2 {
display: inline-flex;
position: relative;
width: 100%;
max-width: 318px;
max-height: auto; /* Allow the height to adjust proportionally */
float: left;
}
::ng-deep .embed-vimeo {
display: inline-flex;
/* You can assign any css properties */
}
::ng-deep .embed-dailymotion {
display: inline-flex;
/* You can assign any css properties */
}
Demjhon Silver