@@ -58,10 +58,7 @@ If you're already using `@supabase/supabase-js`, access storage through the clie
5858``` js
5959import { createClient } from ' @supabase/supabase-js'
6060
61- const supabase = createClient (
62- ' https://<project_ref>.supabase.co' ,
63- ' <your-anon-key>'
64- )
61+ const supabase = createClient (' https://<project_ref>.supabase.co' , ' <your-anon-key>' )
6562
6663// Access storage
6764const storage = supabase .storage
@@ -94,6 +91,7 @@ const analyticsBucket = storageClient.analytics // Analytics API
9491```
9592
9693> ** When to use each approach:**
94+ >
9795> - Use ` supabase.storage ` when working with other Supabase features (auth, database, etc.)
9896> - Use ` new StorageClient() ` for storage-only applications or when you need fine-grained control
9997
@@ -108,7 +106,7 @@ Standard buckets for storing files, images, videos, and other assets.
108106``` js
109107// Create regular storage bucket
110108const { data , error } = await storageClient .createBucket (' my-files' , {
111- public: false
109+ public: false ,
112110})
113111
114112// Upload files
@@ -130,7 +128,7 @@ const bucket = storageClient.vectors.from('embeddings-prod')
130128await bucket .createIndex ({
131129 indexName: ' documents' ,
132130 dimension: 1536 ,
133- distanceMetric: ' cosine'
131+ distanceMetric: ' cosine' ,
134132})
135133```
136134
@@ -290,6 +288,7 @@ Supabase Storage provides specialized analytics buckets using Apache Iceberg tab
290288### What are Analytics Buckets?
291289
292290Analytics buckets use the Apache Iceberg open table format, providing:
291+
293292- ** ACID transactions** for data consistency
294293- ** Schema evolution** without data rewrites
295294- ** Time travel** to query historical data
@@ -299,13 +298,15 @@ Analytics buckets use the Apache Iceberg open table format, providing:
299298### When to Use Analytics Buckets
300299
301300** Use analytics buckets for:**
301+
302302- Time-series data (logs, metrics, events)
303303- Data lake architectures
304304- Business intelligence and reporting
305305- Large-scale batch processing
306306- Analytical workloads requiring ACID guarantees
307307
308308** Use regular storage buckets for:**
309+
309310- User file uploads (images, documents, videos)
310311- Individual file management
311312- Content delivery
@@ -320,10 +321,7 @@ You can access analytics functionality through the `analytics` property on your
320321``` typescript
321322import { createClient } from ' @supabase/supabase-js'
322323
323- const supabase = createClient (
324- ' https://your-project.supabase.co' ,
325- ' your-anon-key'
326- )
324+ const supabase = createClient (' https://your-project.supabase.co' , ' your-anon-key' )
327325
328326// Access analytics operations
329327const analytics = supabase .storage .analytics
@@ -371,6 +369,7 @@ if (error) {
371369```
372370
373371** Returns:**
372+
374373``` typescript
375374{
376375 data : {
@@ -394,25 +393,27 @@ const { data, error } = await analytics.listBuckets({
394393 offset: 0 ,
395394 sortColumn: ' created_at' ,
396395 sortOrder: ' desc' ,
397- search: ' prod'
396+ search: ' prod' ,
398397})
399398
400399if (data ) {
401400 console .log (` Found ${data .length } analytics buckets ` )
402- data .forEach (bucket => {
401+ data .forEach (( bucket ) => {
403402 console .log (` - ${bucket .id } (created: ${bucket .created_at }) ` )
404403 })
405404}
406405```
407406
408407** Parameters:**
408+
409409- ` limit?: number ` - Maximum number of buckets to return
410410- ` offset?: number ` - Number of buckets to skip (for pagination)
411411- ` sortColumn?: 'id' | 'name' | 'created_at' | 'updated_at' ` - Column to sort by
412412- ` sortOrder?: 'asc' | 'desc' ` - Sort direction
413413- ` search?: string ` - Search term to filter bucket names
414414
415415** Returns:**
416+
416417``` typescript
417418{
418419 data : AnalyticBucket [] | null
@@ -428,15 +429,15 @@ const firstPage = await analytics.listBuckets({
428429 limit: 100 ,
429430 offset: 0 ,
430431 sortColumn: ' created_at' ,
431- sortOrder: ' desc'
432+ sortOrder: ' desc' ,
432433})
433434
434435// Fetch second page
435436const secondPage = await analytics .listBuckets ({
436437 limit: 100 ,
437438 offset: 100 ,
438439 sortColumn: ' created_at' ,
439- sortOrder: ' desc'
440+ sortOrder: ' desc' ,
440441})
441442```
442443
@@ -455,6 +456,7 @@ if (error) {
455456```
456457
457458** Returns:**
459+
458460``` typescript
459461{
460462 data : { message : string } | null
@@ -503,11 +505,7 @@ try {
503505The library exports TypeScript types for analytics buckets:
504506
505507``` typescript
506- import type {
507- AnalyticBucket ,
508- BucketType ,
509- StorageError ,
510- } from ' @supabase/storage-js'
508+ import type { AnalyticBucket , BucketType , StorageError } from ' @supabase/storage-js'
511509
512510// AnalyticBucket type
513511interface AnalyticBucket {
@@ -526,15 +524,15 @@ interface AnalyticBucket {
526524``` typescript
527525async function bucketExists(bucketName : string ): Promise <boolean > {
528526 const { data, error } = await analytics .listBuckets ({
529- search: bucketName
527+ search: bucketName ,
530528 })
531529
532530 if (error ) {
533531 console .error (' Error checking bucket:' , error .message )
534532 return false
535533 }
536534
537- return data ?.some (bucket => bucket .id === bucketName ) ?? false
535+ return data ?.some (( bucket ) => bucket .id === bucketName ) ?? false
538536}
539537```
540538
@@ -575,7 +573,7 @@ async function getAllAnalyticsBuckets() {
575573 limit ,
576574 offset ,
577575 sortColumn: ' created_at' ,
578- sortOrder: ' desc'
576+ sortOrder: ' desc' ,
579577 })
580578
581579 if (error ) {
@@ -629,10 +627,7 @@ If you're using the full Supabase client:
629627``` typescript
630628import { createClient } from ' @supabase/supabase-js'
631629
632- const supabase = createClient (
633- ' https://your-project.supabase.co' ,
634- ' your-anon-key'
635- )
630+ const supabase = createClient (' https://your-project.supabase.co' , ' your-anon-key' )
636631
637632// Access vector operations through storage
638633const vectors = supabase .storage .vectors
@@ -1085,7 +1080,6 @@ The storage-js package uses multiple build scripts to generate different module
10851080| ` build :module ` | **ES Modules build** | ` dist / module / ` - Modern ES6 modules with TypeScript definitions |
10861081| ` build :umd ` | **UMD build** | ` dist / umd / ` - Universal Module Definition for browsers/CDN |
10871082| ` clean ` | **Clean build artifacts** | Removes ` dist / ` and ` docs / v2 / ` directories |
1088- | ` format ` | **Format code** | Runs Prettier on all TypeScript files |
10891083
10901084#### Running Builds
10911085
@@ -1316,4 +1310,4 @@ The test infrastructure (`infra/docker-compose.yml`) includes:
13161310
13171311We welcome contributions! Please see our [Contributing Guide](../../../CONTRIBUTING.md) for details on how to get started.
13181312
1319- For major changes or if you're unsure about something, please open an issue first to discuss your proposed changes.
1313+ For major changes or if you're unsure about something, please open an issue first to discuss your proposed changes.
0 commit comments