Eazip

@eazip/react

The recommended React hook, provider, and tray APIs.

@eazip/react adds React state and a ready-made progress UI on top of @eazip/core.

npm install @eazip/react

Most applications use two exports:

import { EazipTray, useEazip } from '@eazip/react';

useEazip()

Returns the command used to start a ZIP and the current task state.

function ExportButton({ files }) {
  const zip = useEazip();

  return (
    <button
      disabled={zip.isBusy}
      onClick={() => zip.download({ files, zipName: 'export.zip' })}
    >
      Download as ZIP
    </button>
  );
}

Returned members

MemberDescription
download(options)Starts a ZIP task and returns its id immediately.
taskThe current task, or null.
isBusytrue while the current task is processing.
cancel(taskId?)Cancels and clears a task.
retry(taskId?)Repeats a retained failed or expired task.
dismiss(taskId?)Removes the task from the UI.
downloadZip(taskId, index)Downloads one completed ZIP part.
downloadAll(taskId?)Downloads every completed ZIP part.

download() creates the ZIP locally by default:

zip.download({
  files,
  zipName: 'export.zip',
  autoDownload: true,
});

The commonly used options are:

OptionDefaultDescription
filesrequiredFiles, blobs, URLs, or source objects.
zipNamedownload.zipOutput ZIP name.
strategy'local'Use 'cloud' for Eazip Cloud.
autoDownloadprovider setting or trueStart the browser download when ready.
failOnUrlErrorfalse locallyFail instead of returning a partial ZIP.
maxZipSizeBytesSplit output into multiple ZIPs near this size.
signalExternal cancellation signal.

Cloud uses the same command:

zip.download({
  strategy: 'cloud',
  publicKey: 'pk_ez_...',
  files: urls,
});

For task fields, error behavior, and backend-created sessions, see the useEazip() guide.

<EazipTray />

Renders progress, cancellation, partial results, retry actions, and completed downloads. Place it once in the application; no stylesheet import is required.

function App() {
  return (
    <>
      <Exporter />
      <EazipTray />
    </>
  );
}

Common props

PropDefaultDescription
placement'corner''corner', 'bar', or 'anchored'.
theme'auto''light', 'dark', or the system preference.
accent'#3056d3'Accent color for progress and actions.
autoDownloadstore settingOverrides automatic download behavior.
autoHideMs20000Delay before hiding a completed tray; 0 disables it.
locale'en'Built-in 'en' or 'ja' messages.
messagesOverrides selected tray messages.
onStateChangeRuns when task identity or lifecycle state changes.

For portal placement, embedding, accessibility, and every visual option, see the <EazipTray /> guide.

<EazipProvider />

The provider is optional. Add it when several components need shared defaults, or when a test or application root needs isolated Eazip state.

import { EazipProvider } from '@eazip/react';

<EazipProvider
  config={{
    strategy: 'cloud',
    publicKey: 'pk_ez_...',
    defaults: { zipName: 'export.zip' },
  }}
>
  <App />
</EazipProvider>
ConfigDescription
strategyDefault local or Cloud strategy.
publicKey / apiBaseUrlShared Cloud connection defaults.
defaultsShared ZIP name, compression, mode, failure, and splitting defaults.
autoDownloadDefault automatic-download behavior.
persist / storageKeyPersistence settings for resumable Cloud tasks.

Values passed directly to download() take precedence over provider defaults.