Skip to main content

Web API Preview

@nitrakit/web, also re-exported by @nitrakit/react, @nitrakit/vue, @nitrakit/svelte and @nitrakit/angular. The whole web API is in preview. Times are microseconds.

Functions​

load(wasmUrl?): Promise<void>Starts the SDK. Call once, first.
isSupported(): booleanThe browser has WebGPU and WebCodecs.
setLicense(key): LicenseStatusInstalls your license key.
licenseInfo(): LicenseStatusThe installed license.
setLocale(tag = navigator.language): stringThe editor's language; returns the one used.
availableLocales(): string[]Built-in languages.
localeIsRtl(): booleanThe current language is right to left.
setStrings(strings)Your own wording: message id → text.
createEditor(options?): Promise<Editor>A new editor.

createEditor options​

Option
preview?, editor?Elements to show the preview and the controls in (or mount them later).
width?, height?, fps?The project's size and frame rate. Default 1080×1920 at 30 fps.
fonts?TTF / OTF URLs or bytes. Default: Inter.
resolveMedia?(id)Where a media id lives: a URL (signed or not) or the file.
layout?auto (by width), desktop or phone.
chrome?false shows only the timeline.
theme?The editor's look; see Theme.
hiddenMenuItems?, menuItems?See Tools and menus.
icons?Icon name → SVG.
onCustomItem?(id)One of your tools was tapped.
stickerPacks?Your sticker packs; see Stickers.
resolveFont?(family)Where a font lives; see Fonts.
keyboard?Editing shortcuts. Default true.
onRequest?(request)Your pickers: return the answer, null (cancelled) or undefined (built-in picker).
onChange?()After every change.
onSelect?(clip)The selected clip changed; "" for none.
onFullscreen?()The fullscreen button was pressed. Default: the preview goes fullscreen.

Editor​

mountPreview(el), mountEditor(el)Show the preview / controls in an element.
unmountPreview(), unmountEditor()Take them off the page; the editor keeps running.
addMedia(id, file?, { name? }): Promise<MediaInfo>Adds media under your id, from a File, Blob or URL (else resolveMedia).
setMediaProgress(id, fraction | null)Progress on a media id's clips, e.g. while uploading.
retryMedia(id?)Resolves a media id (or every missing one) again.
mediaIds(): string[]The media ids the project uses.
addTrack(kind, magnetic): stringvisual, audio or effects; returns the track id.
insertMedia(track, source, startUs, sourceInUs, durationUs): stringReturns the clip id.
insertText(track, startUs, durationUs, text): stringReturns the clip id.
undo(), redo(), canUndo(), canRedo()
selectedClipThe selected clip, "" if none.
toJson(): stringThe project as JSON.
openProject(json)Opens a saved project; its media arrives through resolveMedia.
play(), pause(), seek(us)
playing, positionUs, durationUs
export(options?): Promise<Blob>MP4. Options: shortSide, onProgress, signal.
setChrome(visible)Transport row and bottom bar, or only the timeline.
setTheme(theme)The editor's look.
hideMenuItems(ids), addMenuItem(item), removeMenuItem(id)Tools in the bar.
setIcon(name, svg), iconNames()Icons.
setStickerPacks(packs), setFonts(families)Sticker browser and font panel contents.
loadFont(font), fontFamilies()
effectCatalog(), textStyles()For your own pickers.
setOptions(options)Change callbacks, chrome or layout.
destroy()Stops the editor and frees its memory.

MediaInfo: { source, id, kind, durationUs, width, height, hasAudio, exportable }. exportable is false for videos that aren't H.264 MP4.

Framework packages​

PackageExports
@nitrakit/reactuseNitrakitEditor(options), <NitrakitPreview editor>, <NitrakitEditor editor>
@nitrakit/vueuseNitrakitEditor(options), <NitrakitPreview :editor>, <NitrakitEditor :editor>
@nitrakit/svelteuse:preview={editor}, use:controls={editor}
@nitrakit/angular[nitrakitPreview]="editor", [nitrakitEditor]="editor" (standalone directives)