🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@swmansion/smelter-web-wasm

Package Overview
Dependencies
Maintainers
8
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@swmansion/smelter-web-wasm

Smelter server running directlly in browser

latest
npmnpm
Version
0.2.1
Version published
Maintainers
8
Created
Source

@swmansion/smelter-web-wasm

Provides API to create and manage Smelter instances for browser environment. Smelter rendering engine is compiled to WASM and runs entirely in the browser without any additional infrastructure.

Caution: Browser support is limited to Google Chrome and other Chromium based browsers. Support for Safari and Firefox is planned.

Usage

import { useCallback } from 'react';
import Smelter, { setWasmBundleUrl } from '@swmansion/smelter-web-wasm';
import { View, Text, InputStream } from '@swmansion/smelter';

setWasmBundleUrl('/assets/smelter.wasm'); // URL to WASM bundle

function SmelterApp() {
  return (
    <View>
      <InputStream inputId="camera-input" />
      <Text style={{ fontSize: 20 }}>Hello world</Text>
    </View>
  );
}

function BrowserApp() {
  const videoRef = useCallback(
    async (video: HTMLVideoElement | null) => {
      if (video) {
        await startSmelterInstance(video);
      }
    },
    []
  );

  return <video ref={videoRef} />
}

async function startSmelterInstance(video: HTMLVideoElement) {
  const smelter = new Smelter();
  await smelter.init();

  // register input/outputs/images/shaders/...

  await smelter.registerInput('camera-input', { type: 'camera' });

  const { stream } = await smelter.registerOutput('output', <SmelterApp />, {
    type: 'whip',
    endpointUrl: 'https://example.com/whip',
    bearerToken: '<EXAMPLE TOKEN>',
    video: {
      resolution: { width: 1920, height: 1080 },
    },
    audio: true,
  });

  await smelter.start();

  video.srcObject = stream;
  await video.play();
}

In this example, BrowserApp represents regular React website that hosts the smelter instance and SmelterApp is a totally separate React tree that represents a rendered video.

The final video is both sent over WHIP protocol and the preview is displayed with <video /> tag on the website.

See our docs to learn more.

Configuration

In the example above, we are calling setWasmBundleUrl that should point to the WASM bundle that is part of the @swmansion/smelter-browser-render package.

To learn how to configure it in your project check out our example configurations.

License

@swmansion/smelter-web-wasm is licensed under a custom license.

Smelter is created by Software Mansion

swm

Since 2012 Software Mansion is a software agency with experience in building web and mobile apps as well as complex multimedia solutions. We are Core React Native Contributors and experts in live streaming and broadcasting technologies. We can help you build your next dream product – Hire us.

FAQs

Package last updated on 12 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts