Files
supabase/apps/reference/_supabase_js/generated/storage-deletebucket.mdx
2022-08-23 13:05:23 +08:00

58 lines
1.3 KiB
Plaintext

---
id: storage-deletebucket
title: 'deleteBucket()'
slug: /storage-deletebucket
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Deletes an existing bucket. A bucket can't be deleted with existing objects inside it.
You must first `empty()` the bucket.
```js
const { data, error } = await supabase.storage.deleteBucket('avatars')
```
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
id
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The unique identifier of the bucket you would like to delete.
</div>
</li>
</ul>
## Notes
- RLS policy permissions required:
- `buckets` table permissions: `select` and `delete`
- `objects` table permissions: none
- Refer to the [Storage guide](/docs/guides/storage#access-control) on how access control works
## Examples
### Delete bucket
```js
const { data, error } = await supabase.storage.deleteBucket('avatars')
```