Nosmai  Effects Nosmai  Moderation Nosmai Try-ons coming soon
Docs menu Web
Tutorial

Web quickstart

Verify an origin-bound license, start the browser camera, and apply a compatible .nosmai effect in a WebGL2 canvas.

Platform Web SDK version 0.2.0 developer preview Updated Aug 19, 2026 Time 15 min

Prerequisites

  • Nosmai Effects Web preview installed
  • An authorized Web licence key and public verification key
  • A compatible first-effect.nosmai package
  • A secure context through HTTPS or localhost
  • A camera browser with WebGL2, WebAssembly, and Web Crypto

The Web preview does not expose the mobile SDK's direct skin-smoothing method. This first visible effect therefore uses an authored package instead of claiming native beauty parity.

1. Add the preview canvas

Add these elements to the existing page:

<canvas id="preview"></canvas>
<button id="start" type="button">Start camera effect</button>
<p id="status">Ready to start</p>
<script type="module" src="/src/main.ts"></script>

2. Add licence configuration

Create src/nosmai-config.ts and insert the public verification key supplied with the authorized preview distribution:

export const NOSMAI_LICENSE_KEY = 'NOSMAI-YOUR-WEB-KEY'

export const NOSMAI_LICENSE_PUBLIC_KEY = [
  '-----BEGIN PUBLIC KEY-----',
  'REPLACE_WITH_THE_AUTHORIZED_PUBLIC_KEY_BODY',
  '-----END PUBLIC KEY-----',
].join('\n')

The public verification key is not the project licence key. Do not replace it with a private signing key.

3. Initialize and start the camera

Connect the button to the SDK in src/main.ts:

import { NosmaiWebSDK } from '@nosmai/web-sdk'
import {
  NOSMAI_LICENSE_KEY,
  NOSMAI_LICENSE_PUBLIC_KEY,
} from './nosmai-config'

const canvas = document.querySelector<HTMLCanvasElement>('#preview')!
const startButton = document.querySelector<HTMLButtonElement>('#start')!
const statusLabel = document.querySelector<HTMLParagraphElement>('#status')!

startButton.addEventListener('click', async () => {
  const sdk = await NosmaiWebSDK.create({
    canvas: canvas,
    camera: {
      facingMode: 'user',
      width: 1280,
      height: 720,
    },
    license: {
      publicKeyPem: NOSMAI_LICENSE_PUBLIC_KEY,
      sdkVersion: '0.2.0',
    },
  })

  const licenceStatus = await sdk.verifyLicense(NOSMAI_LICENSE_KEY)
  if (licenceStatus !== 'valid') {
    statusLabel.textContent = `Licence status: ${licenceStatus}`
    return
  }

  await sdk.startCamera()
  const result = await sdk.applyEffect('/filters/first-effect.nosmai')
  console.info('Effect compatibility', result.compatibility)
  statusLabel.textContent = 'Camera ready with Nosmai effect'

  window.addEventListener('pagehide', () => sdk.destroy(), { once: true })
})

Put the compatible package at:

public/filters/first-effect.nosmai

The explicit button preserves the browser user gesture used for camera permission. The compatibility report identifies package primitives that are not implemented by the current Web preview.

4. Run the development server

Use the project's normal bundler command. For a Vite application:

npm run dev

Open the localhost URL and press Start camera effect.

Verify it worked

You should see the live camera rendered into the canvas, the selected authored effect, and the status Camera ready with Nosmai effect. Check the console compatibility report and confirm it does not list a required primitive as unsupported.

Common errors

ErrorCauseFix
UNSUPPORTED_BROWSERRequired browser API is unavailableUse a modern browser in HTTPS or localhost context
WEBGL_UNAVAILABLEWebGL2 context creation failedEnable hardware acceleration or use another supported browser or GPU
CAMERA_PERMISSIONUser or browser policy denied camera accessGrant camera permission and allow camera access on any parent iframe
LICENSE_UNVERIFIEDLicence options are absent or verification was not completedSupply the authorized public key and call verifyLicense
INVALID_PACKAGESelected file is not a valid protected Nosmai packageUse an authorized compatible .nosmai package without modifying its bytes
UNSUPPORTED_EFFECTPackage requires a primitive missing from Web 0.2.0Use a compatible package or target a mobile SDK for that effect

Next steps

References

Was this page helpful?

Your response helps us prioritize documentation improvements.

Nosmai

An AR and AI company. Founded on the idea that the next decade of software will be visual, and that the tools for it should be within reach of anyone building.

Newsletter

Product updates and release notes. No spam.

© 2026 nosmai, inc · all rights reserved