Skip to content

Download URL

The DownloadURL component retrieves a download URL for a file in a Supabase Storage bucket.

This component must be a child of the SupabaseApp component to work.

Props

PropTypeDefaultRequiredDescription
bucketNamestringYesThe name of the bucket containing the file.
pathstringYesThe path to the file in the bucket.
expirationnumber60NoThe number of seconds until the download URL expires.

Slots

NameDescription
defaultThe default slot that receives the download URL, storage client, and any errors.

Usage

<script lang="ts">
import { BucketContext, BucketFilesList } from 'supasveltekit';
</script>
<DownloadURL bucketName="my-bucket" path="path/to/file.jpg" let:url let:storage let:error expiration={3600}>
{#if url}
<a href={url} download>Download file</a>
{:else if error}
<p>Error: {error.message}</p>
{:else}
<p>Loading...</p>
{/if}
</DownloadURL>