The Supabase storage driver integrates with Supabase Storage, providing object storage tightly integrated with PostgreSQL and Supabase’s authentication system. It’s ideal for projects already using Supabase or wanting PostgreSQL-backed storage.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/directus/directus/llms.txt
Use this file to discover all available pages before exploring further.
Installation
The Supabase driver is included by default with Directus via the@directus/storage-driver-supabase package.
Configuration
Configure Supabase storage using environment variables:Configuration Options
The Supabase Storage bucket name where files will be stored.
Supabase service role key for server-side API access with full permissions.
Your Supabase project ID. Required unless using custom
endpoint.Custom Supabase Storage endpoint URL for self-hosted instances. Default:
https://{projectId}.supabase.co/storage/v1.Optional path prefix for organizing files within the bucket.
Chunk size for resumable uploads in bytes. Default:
262144 (256 KiB).Authentication
The driver requires a service role key from/packages/storage-driver-supabase/src/index.ts:48-60:
- Get your service role key from Supabase Dashboard > Settings > API
- Service role bypasses Row Level Security (RLS)
- Keep service role key secret - never expose to clients
Examples
Basic Configuration
With Root Path
Self-Hosted Supabase
With Custom Chunk Size
Features
Resumable Uploads
The Supabase driver supports TUS resumable uploads from/packages/storage-driver-supabase/src/index.ts:24-301:
- Uses tus-js-client library
- Creates resumable upload sessions
- Automatic retry on network failures
- Upload URL preservation for resume capability
- Supports upsert (overwrite existing files)
TUS Implementation
From/packages/storage-driver-supabase/src/index.ts:238-292:
- Custom StreamSource for handling Node.js streams
- Automatic upload URL caching
- Resume from previous upload using session data
- Chunk-based progress tracking
PostgreSQL Integration
Supabase Storage uses PostgreSQL:- File metadata stored in PostgreSQL
- Row Level Security (RLS) support
- Trigger-based hooks available
- Transactional consistency
Authenticated URLs
From/packages/storage-driver-supabase/src/index.ts:78-80:
- Files accessed via authenticated endpoints
- Service role provides full access
- Can implement custom RLS policies
Implementation Details
The Supabase driver (DriverSupabase class) from /packages/storage-driver-supabase/src/index.ts:24-333:
- Uses
@supabase/storage-jsSDK - Custom dirname implementation for path handling from
/packages/storage-driver-supabase/src/index.ts:306-308 - Special handling for current directory (empty string) from
/packages/storage-driver-supabase/src/index.ts:74-75 - Paginated listing with recursive directory traversal from
/packages/storage-driver-supabase/src/index.ts:169-228
List Implementation
From/packages/storage-driver-supabase/src/index.ts:169-228:
- Handles directories vs files (null ID = directory)
- Recursive directory traversal
- Search-based filtering
- Pagination with 1000 item limit
- Parent directory prefix handling
StreamSource Extension
From/packages/storage-driver-supabase/src/index.ts:311-325:
- Custom tus-js-client StreamSource
- Single-chunk stream handling
- Offset adjustment for chunk boundaries
- Prevents multiple reads of single chunk
Best Practices
Service Role Security
Protect your service role key:Bucket Configuration
Create and configure your bucket in Supabase Dashboard:Row Level Security
While service role bypasses RLS, configure policies for direct client access:Public vs Private Buckets
- Private buckets - Require authentication for all access
- Public buckets - Allow unauthenticated reads
File Paths
From/packages/storage-driver-supabase/src/index.ts:71-76:
- Current directory represented as empty string
- Leading slashes normalized
- Path joining handles edge cases
Storage Limits
Supabase storage limits by plan:- Free: 1 GB
- Pro: 100 GB (additional storage available)
- Enterprise: Custom
Performance Optimization
- Use Supabase CDN for global distribution
- Enable image transformations in bucket settings
- Configure appropriate CORS policies
- Use chunk size appropriate for your network
Metadata and Search
From/packages/storage-driver-supabase/src/index.ts:108-128:
- File metadata available via stat()
- Search by filename in list operations
- Metadata stored in PostgreSQL
Advanced Features
Image Transformations
Supabase supports URL-based image transformations:- Width/height resizing
- Quality adjustment
- Format conversion
Webhooks
Configure PostgreSQL triggers for storage events:Direct PostgreSQL Queries
Query file metadata directly:Troubleshooting
Authentication Errors
- Verify service role key is correct (not anon key)
- Check project ID matches your Supabase project
- Ensure service role hasn’t been rotated
- Test with:
curl -H "Authorization: Bearer {key}" {endpoint}/bucket
Bucket Not Found
Ensure bucket exists:Upload Failures
- Check storage quota hasn’t been exceeded
- Verify file size is within limits
- Ensure bucket accepts uploads (not read-only)
- Check network connectivity to Supabase
List Operation Issues
From/packages/storage-driver-supabase/src/index.ts:169-228:
- Empty results may indicate wrong prefix
- Directory vs file handling (ID null = directory)
- Search term case sensitivity
- Pagination limits (1000 items per page)
Resumable Upload Errors
- Verify TUS endpoint is accessible
- Check upload URL persistence in context
- Ensure chunk size is appropriate
- Verify metadata is correctly passed
Self-Hosted Issues
- Verify endpoint URL includes
/storage/v1 - Check Supabase services are running
- Ensure PostgreSQL connection is healthy
- Verify Kong gateway configuration