Upload queue example

Process files locally.

This handler reads and hashes local files. It demonstrates queue callbacks without pretending to upload or store anything.

Complete React client module · MIT · Next.js and Vite

Interactive example

Process files locally

This handler reads and hashes local files. It demonstrates queue callbacks without pretending to upload or store anything.

Loads this example when you need it.

Keyboard

  • Tab reaches Browse, Start and each file action.
  • Cancel aborts the local attempt.

States covered

  • Queued
  • Locally processing
  • Receipt
  • Cancelled

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-basic-upload-queue.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import {UploadQueue,type UploadFileHandler} from '@bld8/ui';
import '@bld8/ui/styles.css';
const processFile:UploadFileHandler=async(file,{signal,requestId,onProgress})=>{
  const bytes=await file.arrayBuffer();if(signal.aborted)throw new DOMException('Cancelled','AbortError');
  const digest=await crypto.subtle.digest('SHA-256',bytes);if(signal.aborted)throw new DOMException('Cancelled','AbortError');
  onProgress({loaded:file.size,total:file.size});
  const sha256=Array.from(new Uint8Array(digest),value=>value.toString(16).padStart(2,'0')).join('');
  return {id:'local-'+requestId,requestId,bytes:file.size,sha256};
};
export default function QueueExample(){return <div><p>No files leave this browser. The handler reads and hashes each file locally; this is not an upload service.</p><UploadQueue label="Example local file processor" onUploadFile={processFile} maxFiles={3} maxSize={2*1024*1024} concurrency={1}/></div>;}