Runtime Guides
Browser Runtime
Encode placeholders from File, Blob, ArrayBuffer, or CORS-enabled remote URLs in client code.
- entrypoint
- blurkit/browser
- backend
- browser APIs
- install
- none
Why this runtime
Use blurkit/browser when the user provides an image in the client and you need a local preview placeholder.
Encode a user upload
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)}Accepted inputs
- Supported inputs:
FileBlobArrayBufferUint8Array- remote URL string or
URLwhen CORS allows fetch and decode
- Includes
encodeMany()andencodeManySettled().
Browser constraints
- Local filesystem paths are not supported.
- Remote URL flow fails when CORS blocks image decode.