Storage Providers
Configure AWS S3 (or any S3-compatible provider).
The storage package supports multiple cloud providers through unstorage drivers. This guide covers setup for each provider.
Local Filesystem (Development)
The filesystem driver is enabled by default in development:
.env.local
# .env.localSTORAGE_PROVIDER=fsSTORAGE_BASE_URL=storage.devFiles are stored locally and served via Next.js static file serving.
Note: Filesystem storage is disabled in production (NODE_ENV === 'production').
AWS S3 (or any S3-compatible provider)
Environment Variables
.env.production
# .env.productionSTORAGE_PROVIDER=s3STORAGE_BASE_URL=https://my-bucket.s3.us-east-1.amazonaws.comSTORAGE_S3_ACCESS_KEY_ID=your-access-keySTORAGE_S3_SECRET_ACCESS_KEY=your-secret-keySTORAGE_S3_REGION=us-east-1STORAGE_S3_BUCKET=my-bucketWarning: Do not add the secret access key to the environment variables file. Instead, use your hosting provider to set the environment variable.
Custom Provider
Register any unstorage-compatible driver:
packages/storage/src/registry.ts
import { storageRegistry, createStorage } from '@kit/storage';import customDriver from './my-custom-driver';storageRegistry.register('custom', async () => { return createStorage({ driver: customDriver({ // Driver options }), });});Then set:
STORAGE_PROVIDER=customNext: API Reference