Skip to main content

useSyncsnapJob

useSyncsnapJob creates a transfer job, then calls your backend’s wait endpoint. The server polls until the job completes or fails and returns the final job plus a result (e.g. presigned download URL or a custom payload from your server’s onCompleted callback). The hook passes that result to your onCompleted(job, result). It powers SyncsnapUploadButton and can be used on its own for custom UIs.

Basic usage

  • Call start() to create a job and call the wait endpoint (server does the polling).
  • jobId is set once the job is created; use it with SyncsnapQrCode or createUploadUrl.
  • status is the current job status; isWaiting is true while the wait request is in flight.
  • onCompleted(job, result) runs when the job finishes; result is what your server’s onCompleted returned, or the presigned download URL when no callback is set.

Options

Return value

Custom URLs

Use a different API base path:

Wait timeout and interval

The client sends timeoutMs and intervalMs as query params to the wait endpoint. Override the defaults:

Auto-start

Create and call the wait endpoint as soon as the component mounts:
Use with care (e.g. dedicated page) so you don’t create jobs unnecessarily.

Reset

Call reset() to abort the wait and clear state (e.g. when the user closes the dialog):

API reference

Full types: useSyncsnapJob (API).