Skip to main content

useImageUpload
hook

The useImageUpload hook provides functionality for uploading images attached to the current user. It handles the upload process, including getting upload links, uploading to storage, and polling for completion.

Anchor to useImageUpload
useImageUpload()

UseImageUploadReturns

uploadImage
(image: File) => Promise<[]>

Upload an image which will be attached to the current user.

Was this section helpful?

Example code

import {useCallback} from 'react'

import {useImageUpload, Button} from '@shopify/shop-minis-react'

export default function MyComponent() {
const {uploadImage} = useImageUpload()

const handleUpload = useCallback(async () => {
const result = await uploadImage([
{
mimeType: 'image/jpeg',
uri: 'file://path/to/image.jpg',
},
])
console.log('Uploaded image:', result[0])
}, [uploadImage])

return <Button onClick={handleUpload}>Upload image</Button>
}