Skip to main content

Streaming and asynchronous jobs

@markpdf/react combines two different things: upload progress (inherited from the useConvertFile hook, via XMLHttpRequest) and streaming/jobs from API (inherited from the base client @markpdf/sdk, via useMarkpdf()).

Upload progress with useConvertFile

  • status goes through "idle" → "uploading" → "converting" → "success"|"error".
  • progress only makes sense during "uploading" (percentage of bytes uploaded). During "converting" the server has already received the complete file and is processing it; there is no granular progress from that phase.
This covers POST /convert (multipart). It does not apply to convertFromUrl, where there are no bytes to upload from the browser.

Streaming Markdown with useMarkpdf()

To consume /convert/stream chunk by chunk, use the raw client:

Jobs due to saturation (202)

useConvertFile().convert() does not automatically poll queued jobs — if API responds 202, the hook’s error will be MarkpdfError with the job detail. To handle it, use the raw client with autoPoll (the default):
useConvertFile() is intended for the common “upload with progress bar” case. If you need explicit handling of 202/job retries, combine useMarkpdf() (base client with autoPoll) instead of useConvertFile().
Results for completed jobs expire in approximately 1 hour. If you save a jobId and query client.getJob(jobId) later and receive 404, resend the original conversion.