Skip to content

Runtime Guides

Browser Runtime

Encode placeholders from File, Blob, ArrayBuffer, or CORS-enabled remote URLs in client code.

Use blurkit/browser when the user provides an image in the client and you need a local preview placeholder.

import { encode } from 'blurkit/browser'
const input = document.querySelector<HTMLInputElement>('#image')
const file = input?.files?.[0]
if (file) {
const result = await encode(file, {
algorithm: 'thumbhash',
outputFormat: 'png',
})
console.log(result.dataURL)
}
  • Supported inputs:
    • File
    • Blob
    • ArrayBuffer
    • Uint8Array
    • remote URL string or URL when CORS allows fetch and decode
  • Includes encodeMany() and encodeManySettled().
  • Local filesystem paths are not supported.
  • Remote URL flow fails when CORS blocks image decode.