Blob quickstart
Store and serve a first file with the local filesystem driver.
This quickstart uses the local filesystem driver because it gives you the fastest first success in local development.
Install the package
Terminal
pnpm add https://pkg.pr.new/vite-hub/vitehub/@vitehub/blob@main
Configure Blob
nuxt.config.ts
export default defineNuxtConfig({
modules: ['@vitehub/blob/nuxt'],
blob: {
driver: 'fs',
dir: '.data/blob',
},
})
Store a file
server/api/files.post.ts
import { blob } from '@vitehub/blob'
export default defineEventHandler(async () => {
return await blob.put('avatars/user-1.txt', 'hello blob', {
contentType: 'text/plain',
})
})
Serve the file
server/routes/files/[...pathname].get.ts
import { blob } from '@vitehub/blob'
export default defineEventHandler(async (event) => {
return await blob.serve(event, 'avatars/user-1.txt')
})
Verify that it worked
Create the file:
Terminal
curl -X POST http://localhost:3000/api/files
Then request the served route and confirm it returns the stored content.
Next steps
- Use Blob SDK for reads, lists, deletes, and other runtime operations.
- Use File uploads for form and multipart upload flows.
- Use Troubleshooting if driver selection or serving fails.