Private storage for Vercel Blob, now available in public beta
Source: Vercel Blog
Overview
Vercel Blob now supports private storage for sensitive files such as contracts, invoices, and internal reports. Private storage requires authentication for all operations, preventing exposure via public URLs.
Public storage continues to allow public reads for media assets, while private storage mandates authentication.
Creating a private store
Create a private store via the Storage dashboard or with the CLI:
vercel blob create-store [name] --access private
Private stores require the BLOB_READ_WRITE_TOKEN environment variable, which is automatically injected when using the SDK.
SDK installation
pnpm add @vercel/blob@2.3
Uploading files
Use put (or upload) with the access: 'private' option.
import { put } from '@vercel/blob';
export async function POST(request: Request) {
// Your auth goes here: await authRequest(request);
const filename = request.nextUrl.searchParams.get('filename');
const blob = await put(filename, request.body, {
access: 'private',
});
return Response.json(blob);
}
Downloading files
Use the get method to stream files.
import { get } from '@vercel/blob';
export async function GET(request: Request) {
// Your auth goes here: await authRequest(request);
const filename = request.nextUrl.searchParams.get('filename');
const { stream, blob } = await get(filename, {
access: 'private',
});
return new Response(stream, {
headers: {
'Content-Type': blob.contentType,
},
});
}
Pricing and availability
Private storage is in beta on all plans and follows the standard Vercel Blob pricing.