JavaScript: listV2

Lists all the files and folders within a bucket using the V2 API with pagination support.

Important: Folder entries in the folders array only contain name and optionally key — they have no id, timestamps, or metadata fields. Full file metadata is only available on entries in the objects array.

this method signature might change in the future

Parameters

Examples

List files with pagination

const { data, error } = await supabase
  .storage
  .from('avatars')
  .listV2({
    prefix: 'folder/',
    limit: 100,
  })

// Handle pagination
if (data?.hasNext) {
  const nextPage = await supabase
    .storage
    .from('avatars')
    .listV2({
      prefix: 'folder/',
      cursor: data.nextCursor,
    })
}

// Handle files vs folders
data?.objects.forEach(file => {
  if (file.id !== null) {
    console.log('File:', file.name, 'Size:', file.metadata?.size)
  }
})
data?.folders.forEach(folder => {
  console.log('Folder:', folder.name)
})