Source:
ocean/docs/assets-blob-storage.md| ✏️ Edit on GitHub
Public Assets on Blob Storage
This project is configured to automatically upload public assets to Vercel Blob Storage for better performance and CDN distribution.
How It Works
- Local Development: Assets are served from the
/publicfolder - Production: Assets are uploaded to Vercel Blob Storage and served from CDN
Asset Upload Process
Automatic Upload on Deploy
The assets:upload script runs automatically during the build process when you use:
pnpm run build:with-assets
Manual Upload
To manually upload assets to blob storage:
pnpm run assets:upload
Configured Assets
The following folders are automatically synced to blob storage:
/public/Cover Image/- Cover images for pages/public/Logomark/- Logo mark variations/public/Primary Logo/- Full logo variations
The following files remain local for performance:
favicon.icologo192.pnglogo512.pngmanifest.jsonrobots.txt
Asset Service
The getAssetUrl() function automatically handles asset URLs:
import { getAssetUrl } from '@/services/asset-service'
// In development: returns "/Cover Image/ocean-beach.jpg"
// In production: returns blob storage URL if available
const imageUrl = getAssetUrl('/Cover Image/ocean-beach.jpg')
Adding New Assets
- Add the asset to the appropriate folder in
/public - Run
pnpm run assets:uploadto upload to blob storage - Use
getAssetUrl()to reference the asset in your code
Benefits
- Better Performance: Assets served from Vercel's global CDN
- Reduced Bundle Size: Static assets don't bloat your JavaScript bundle
- Automatic Optimization: Vercel optimizes delivery based on user location
- Version Control: Large binary files don't bloat your Git repository
Environment Setup
The BLOB_READ_WRITE_TOKEN is automatically available in Vercel deployments. For local testing of the upload script, add it to your .env file:
BLOB_READ_WRITE_TOKEN=vercel_blob_your_token_here
Troubleshooting
Assets not uploading
- Check that
BLOB_READ_WRITE_TOKENis set - Verify the asset is in one of the configured folders
- Check the console output for specific errors
Assets not loading in production
- Ensure the upload script ran during build
- Check that
getAssetUrl()is used instead of hardcoded paths - Verify the asset was successfully uploaded to blob storage