Skip to content

StreamCrafter — Svelte

Terminal window
npm install @livepeer-frameworks/streamcrafter-svelte

Import the CSS once in your app:

<script>
import "@livepeer-frameworks/streamcrafter-svelte/streamcrafter.css";
</script>

The <StreamCrafter /> component is fully self-contained.

Direct WHIP Mode:

<script lang="ts">
import { StreamCrafter } from "@livepeer-frameworks/streamcrafter-svelte";
import "@livepeer-frameworks/streamcrafter-svelte/streamcrafter.css";
</script>
<StreamCrafter whipUrl="https://edge-ingest.frameworks.network/webrtc/stream-key" initialProfile="broadcast" />

Gateway Resolution Mode:

<StreamCrafter gatewayUrl="https://bridge.frameworks.network/graphql" streamKey="abc-123" initialProfile="broadcast" />

Gateway resolution calls the public resolveIngestEndpoint GraphQL field from the publisher’s browser. Use direct whipUrl unless that resolver is enabled in your environment, and prefer the dashboard DNS ingest URL for backend or encoder-side publishing.

Pass a children snippet to replace the default UI with sub-components:

<script lang="ts">
import {
StreamCrafter,
StudioPreview,
StudioMixer,
StudioActionBar,
StudioSettings,
StudioStatusBadge,
} from "@livepeer-frameworks/streamcrafter-svelte";
import "@livepeer-frameworks/streamcrafter-svelte/streamcrafter.css";
</script>
<StreamCrafter whipUrl="https://edge-ingest.frameworks.network/webrtc/my-key">
{#snippet children()}
<div class="my-layout">
<StudioStatusBadge />
<StudioPreview />
<div class="sidebar">
<StudioMixer />
<StudioSettings />
</div>
<StudioActionBar />
</div>
{/snippet}
</StreamCrafter>

Sub-components auto-connect to the parent <StreamCrafter> via Svelte 5 context.

ComponentPurpose
StudioPreviewVideo preview with live badge
StudioMixerSource list with volume sliders, mute, and remove buttons
StudioActionBarCamera, Screen Share, Settings, and Go Live buttons
StudioSettingsQuality profile selector popup
StudioStatusBadgeState badge (Idle, Capturing, Live, etc.)

For complete UI control, use createStreamCrafterContextV2:

<script lang="ts">
import { onMount, onDestroy } from "svelte";
import { createStreamCrafterContextV2 } from "@livepeer-frameworks/streamcrafter-svelte";
const crafter = createStreamCrafterContextV2();
let videoEl: HTMLVideoElement;
onMount(() => {
crafter.initialize({
whipUrl: "https://edge-ingest.frameworks.network/webrtc/key",
profile: "broadcast",
reconnection: { enabled: true },
});
});
onDestroy(() => crafter.destroy());
</script>
<div>
<video bind:this={videoEl} autoplay muted />
<p>State: {$crafter.state}</p>
<p>Sources: {$crafter.sources.length}</p>
<button onclick={() => crafter.startCamera()}>Add Camera</button>
<button onclick={() => crafter.startScreenShare({ audio: true })}>Share Screen</button>
<button
onclick={() => ($crafter.isStreaming ? crafter.stopStreaming() : crafter.startStreaming())}
>
{$crafter.isStreaming ? "Stop" : "Go Live"}
</button>
</div>

The store implements Svelte’s store contract. Read reactive state with $crafter in markup or subscribe manually in script:

PropertyTypeDescription
stateIngestStateCurrent lifecycle state
isStreamingbooleanWhether currently live
isCapturingbooleanWhether media is captured
isReconnectingbooleanWhether reconnecting
sourcesMediaSource[]Active media sources
mediaStreamMediaStream | nullCombined output stream
qualityProfileQualityProfileCurrent quality settings
MethodDescription
startCamera(opts?)Add camera source
startScreenShare(opts?)Add screen share source
startStreaming()Go live
stopStreaming()Stop streaming
removeSource(id)Remove a source
setSourceVolume(id, vol)Set source volume (0-1)
setSourceMuted(id, muted)Mute/unmute source
setQualityProfile(name)Change quality profile
controllerDirect controller access