npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

bulk-upload-ui

v1.0.4

Published

Production-grade, reusable bulk upload UI library for React and Next.js with configurable validation, duplicate handling, and error management

Downloads

364

Readme

bulk-upload-ui

Production-grade, reusable bulk upload UI library for React and Next.js.

npm version npm downloads

Installation

npm install bulk-upload-ui
# or
yarn add bulk-upload-ui

Features

  • Framework-agnostic - Works in React (Vite/CRA) and Next.js (Pages + App Router)
  • SSR-safe - No Next.js-specific APIs, fully client-side compatible
  • TypeScript - Full type safety with comprehensive types
  • Config-driven - No hard-coded URLs, supports auth injection
  • Flexible - Use the main component or individual pieces
  • Customizable - CSS variables for easy theming
  • Production-ready - Error handling, validation, progress tracking

Installation

npm install bulk-upload-ui
# or
yarn add bulk-upload-ui

Quick Start

React (Vite/CRA)

import { BulkUpload } from 'bulk-upload-ui';
import 'bulk-upload-ui/dist/styles/bulk-upload.css'; // Optional

function App() {
  return (
    <BulkUpload
      entity="lead"
      uploadMode="UPSERT"
      apiBaseUrl="/api"
      onComplete={(result) => console.log(result)}
    />
  );
}

Next.js App Router

'use client';

import { BulkUpload } from 'bulk-upload-ui';

export default function Page() {
  return (
    <BulkUpload
      entity="lead"
      uploadMode="UPSERT"
      apiBaseUrl="/api"
      getAuthToken={() => localStorage.getItem('token')}
      onComplete={(result) => console.log(result)}
    />
  );
}

Next.js Pages Router

import { BulkUpload } from 'bulk-upload-ui';

export default function Page() {
  return (
    <BulkUpload
      entity="lead"
      uploadMode="UPSERT"
      apiBaseUrl="/api"
      getAuthToken={() => {
        // Get token from cookies or context
        return document.cookie.match(/token=([^;]+)/)?.[1];
      }}
      onComplete={(result) => console.log(result)}
    />
  );
}

API Reference

BulkUpload Component

Main orchestrator component that handles the entire upload flow.

Props

| Prop | Type | Required | Default | Description | |------|------|----------|---------|-------------| | entity | string | ✅ | - | Entity type (e.g., "lead", "user") | | uploadMode | 'CREATE' \| 'UPDATE' \| 'UPSERT' | ✅ | - | Upload operation mode | | apiBaseUrl | string | ✅ | - | Base URL for API (e.g., "/api") | | getAuthToken | () => string \| null \| Promise<string \| null> | ❌ | - | Function to get auth token | | headers | Record<string, string> | ❌ | {} | Additional HTTP headers | | requiredFields | string[] | ❌ | [] | Required backend fields | | availableFields | string[] | ❌ | [] | Available backend fields for mapping | | showColumnMapper | boolean | ❌ | true | Show column mapping step | | showPreview | boolean | ❌ | true | Show preview step | | maxFileSize | number | ❌ | 10485760 | Max file size in bytes (10MB) | | acceptedFileTypes | string[] | ❌ | ['.csv', '.xlsx', '.xls'] | Accepted file extensions | | onComplete | (result: BulkUploadResult) => void | ❌ | - | Callback when upload completes | | onError | (error: string) => void | ❌ | - | Callback when error occurs | | className | string | ❌ | '' | Additional CSS class | | disabled | boolean | ❌ | false | Disable the component |

useBulkUpload Hook

Hook for managing bulk upload state and operations.

const {
  state,
  handleFileSelect,
  handleMappingChange,
  handleContinueToPreview,
  handleUpload,
  handleDownloadErrorFile,
  reset,
} = useBulkUpload({
  entity: 'lead',
  uploadMode: 'UPSERT',
  config: {
    baseUrl: '/api',
    getAuthToken: () => localStorage.getItem('token'),
  },
  availableFields: ['email', 'name', 'phone'],
  requiredFields: ['email'],
  callbacks: {
    onComplete: (result) => console.log(result),
    onError: (error) => console.error(error),
  },
});

API Client

Direct API client for custom implementations.

import { createBulkUploadClient } from 'bulk-upload-ui';

const client = createBulkUploadClient({
  baseUrl: '/api',
  getAuthToken: () => localStorage.getItem('token'),
});

const result = await client.upload({
  entity: 'lead',
  uploadMode: 'UPSERT',
  file: fileObject,
  onProgress: (progress) => console.log(progress.percentage),
});

Backend API Contract

The library expects a REST API endpoint:

POST /bulk-upload/:entity

Request

  • Content-Type: multipart/form-data
  • Body:
    • file: File (CSV/XLSX)
    • uploadMode: 'CREATE' | 'UPDATE' | 'UPSERT'
    • columnMappings: JSON string of column mappings (optional)

Response

{
  "success": true,
  "status": "SUCCESS" | "PARTIAL_SUCCESS" | "FAILED",
  "totalRows": 100,
  "successfulRows": 95,
  "failedRows": 5,
  "errors": [
    {
      "rowIndex": 0,
      "row": { "email": "invalid", "name": "Test" },
      "errors": ["Invalid email format"]
    }
  ],
  "errorFileUrl": "/api/errors/123.csv",
  "message": "Upload completed with some errors"
}

Customization

CSS Variables

Override CSS variables to customize the appearance:

:root {
  --bulk-upload-primary: #6366f1;
  --bulk-upload-primary-hover: #4f46e5;
  --bulk-upload-success: #10b981;
  --bulk-upload-error: #ef4444;
  --bulk-upload-border-radius: 12px;
  --bulk-upload-spacing: 20px;
}

Individual Components

Use individual components for more control:

import { FilePicker, ColumnMapper, PreviewTable } from 'bulk-upload-ui';

// Use components individually
<FilePicker onFileSelect={handleFile} />
<ColumnMapper fileHeaders={headers} availableFields={fields} />
<PreviewTable data={data} validations={validations} />

Examples

See the examples/ directory for:

  • React example
  • Next.js Pages Router example
  • Next.js App Router example
  • Advanced usage with hooks

TypeScript

Full TypeScript support with exported types:

import type {
  BulkUploadResult,
  BulkUploadProps,
  UploadMode,
  ColumnMapping,
} from 'bulk-upload-ui';

Browser Support

  • Modern browsers (Chrome, Firefox, Safari, Edge)
  • Requires FileReader API support
  • Requires FormData and XMLHttpRequest support

License

MIT