TanStack Query
If you prefer to use TanStack Query instead of the hooks provided by Better Upload, you can do so by using the uploadFile
and uploadFiles
functions with the useMutation
hook from TanStack Query.
Example
The complete code for a simple uploader is below.
Tracking upload state
Note that by directly using the upload functions, you need to track the state of each file upload yourself. This is simple to do, an example for multiple files is below.