Skip to content

Use Cases

Browser Uploader Flow

Generate placeholders in the browser when users upload images in client UI.

Use this pattern when images are selected by users and should not be uploaded just to generate a placeholder.

import { encode } from 'blurkit/browser'
async function handleFile(file: File) {
const result = await encode(file, {
algorithm: 'thumbhash',
size: 32,
})
return {
blurDataURL: result.dataURL,
blurHash: result.hash,
width: result.meta.originalWidth,
height: result.meta.originalHeight,
}
}
  • Use File or Blob input for local user images.
  • meta fields can be stored with upload payloads.
  • thumbhash can reduce payload size for very small placeholders.
  • Remote URL input requires CORS.
  • Browser runtime cannot read local path strings.