JavaScript: Retrieve public URL

A simple convenience function to get the URL for an asset in a public bucket. If you do not want to use this function, you can construct the public URL by concatenating the bucket URL with the path to the asset. This function does not verify if the bucket is public. If a public URL is created for a bucket which is not public, you will not be able to download the asset.

Parameters

Examples

Returns the URL for an asset in a public bucket

const \{ data \} = supabase
  .storage
  .from('public-bucket')
  .getPublicUrl('folder/avatar1.png')

Returns the URL for an asset in a public bucket with transformations

const \{ data \} = supabase
  .storage
  .from('public-bucket')
  .getPublicUrl('folder/avatar1.png', \{
    transform: \{
      width: 100,
      height: 100,
    \}
  \})

Returns the URL which triggers the download of an asset in a public bucket

const \{ data \} = supabase
  .storage
  .from('public-bucket')
  .getPublicUrl('folder/avatar1.png', \{
    download: true,
  \})