Eazip
React

Control tasks with useEazip()

Start ZIP downloads, read the current React task, and share defaults without duplicating engine state.

useEazip() connects a component to the current Eazip task and its actions. Use it whether you render <EazipTray /> or your own interface.

Start a download

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

function DownloadButton({ files }: { files: File[] }) {
  const zip = useEazip();

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

download() starts the task and returns its ID immediately. Processing and network failures appear on task; they are not asynchronous exceptions from the call.

Validate an optional selection first

An empty or unsupported files value fails synchronously. Disable the action or validate the selection when an empty list is a normal UI state.

Read the current task

StateMeaningTypical UI
processingThe Local or Cloud job is runningProgress or an indeterminate status, plus cancel
completedAll output is readyDownload action
partialOutput is ready with skipped filesDownload plus a skipped-count notice
failedNo usable output was producedError and retry when canRetry is true
expiredCloud output is no longer availableStart a new export

isBusy is the short form of checking for a processing task. Use task when the interface needs progress, ZIP parts, errors, or expiry.

Choose the session path

  • Local: download({ files }) runs in the browser.
  • Frontend-created Cloud: add strategy: 'cloud', publicKey, and URL sources.
  • Backend-created Cloud: pass createSession instead of files and publicKey.

See Backend-created sessions for the trusted server boundary.

Share defaults when needed

No provider is required. Add EazipProvider when several components need the same defaults or a test needs isolated state:

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

<EazipProvider
  config={{
    strategy: 'cloud',
    publicKey: 'pk_ez_...',
    defaults: { zipName: 'export.zip' },
  }}
>
  <App />
</EazipProvider>

Per-download options take precedence over provider defaults. See the React Reference for every action, option, task field, and provider setting.