Eazip

@eazip/react

Reference for the React hook, task state, tray props, provider config, localization, and re-exported Core types.

npm install @eazip/react

Requires React and React DOM 18 or later.

useEazip()

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

const zip = useEazip();

Returned members

MemberDescription
download(options)Starts a task and returns its ID immediately.
taskCurrent task or null.
tasksCurrent task as an array; currently contains at most one item.
isBusytrue while the current task is processing.
cancel(taskId?)Aborts and removes the matching or current task.
retry(taskId?)Restarts a retained request.
dismiss(taskId?)Removes the matching or current task.
downloadZip(taskId, zipIndex)Downloads one completed ZIP part.
downloadAll(taskId?)Downloads every completed ZIP part.

Local download options

OptionDefaultDescription
filesrequiredZipInput files, blobs, URLs, or source objects.
strategy'local'Local execution.
zipName'download.zip'Output filename.
compressionLevel6Deflate level from 0 through 9.
concurrency4Parallel Local URL fetches.
onProgressReceives Local progress.

Shared download options

OptionDefaultDescription
failOnUrlErrorfalseFail instead of returning partial output.
maxZipSizeBytesBest-effort output part size.
signalExternal abort signal.
fetchglobal fetchCustom source or Cloud requests.
onChangeReceives underlying Core snapshots.
autoDownloadprovider value or trueDownloads the first output automatically.

Cloud download options

Frontend-created sessions add:

OptionDefaultDescription
strategyrequired 'cloud'Cloud execution.
publicKeyprovider value or requiredBrowser-safe public key.
filesrequiredRemote URL sources.
apiBaseUrlprovider or SDK defaultCloud API origin.
mode'stream'stream or stored.
turnstileToken / onChallengeAnti-abuse challenge handling.
pollingSDK defaultsCloud polling controls.

Backend-created sessions use createSession(context) and optional filesTotal instead of files, publicKey, and challenge options.

EazipTask

FieldDescription
idTask identifier.
stateprocessing, completed, partial, failed, or expired.
strategyLocal or Cloud.
zipNameRequested or resolved archive name.
filesTotalKnown input count.
progressLocal progress or null.
zipsOutput ZIP metadata and download state.
skippedCount / skippedOmitted source count and Local details.
errorSerializable fatal error.
downloadStartedWhether an automatic or manual output download started.
createdAt / expiresAtClient creation time and optional Cloud expiry.
canRetryWhether the original request can be replayed.

<EazipTray />

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

<EazipTray />

Props

PropDefaultDescription
placement'corner'corner, bar, or anchored.
theme'auto'light, dark, or system preference.
accent'#3056d3'CSS accent color.
autoDownloadstore valueOverrides automatic-download behavior.
autoHideMs20000Completed auto-downloaded task delay; 0 disables.
locale'en'Built-in en or ja catalog.
messagesPartial message overrides.
classNameClass on the tray root.
zIndex9999Tray stacking order.
offset{ x?, y? } CSS-pixel placement offset.
containerdocument.bodyPortal target.
onStateChangeCalled on task identity or lifecycle-state changes.

<EazipProvider />

The provider is optional. Its config supplies shared fallbacks and isolated store state.

<EazipProvider
  config={{
    strategy: 'cloud',
    publicKey: 'pk_ez_...',
    defaults: { zipName: 'export.zip' },
  }}
>
  <App />
</EazipProvider>
ConfigDescription
strategyDefault Local or Cloud strategy.
publicKey / apiBaseUrlShared Cloud connection defaults.
defaultsZIP name, compression, mode, failure, and splitting defaults.
autoDownloadShared automatic-download default.
persistEnables resumable Cloud task persistence; defaults to true.
storageKeyOverrides the persistence key.

Options passed directly to download() take precedence.

Localization and re-exports

The package exports en, ja, EazipTrayLocale, and EazipTrayMessages for tray localization. It also re-exports Core error classes and shared types used by the React API, including ZipInput, ZipJob, and progress and output types.