Nuxt Blob Storage

Setup Blob Storage in your Nuxt application to store assets like images, videos, documents. Compatible with AWS S3, Cloudflare R2, Vercel Blob and more.

Getting Started

Enable blob storage

Enable blob storage in your project by setting blob: true in the NuxtHub config.

nuxt.config.ts
export default defineNuxtConfig({
  hub: {
    blob: true
  }
})

Set a driver

NuxtHub automatically configures the blob storage driver based on your environment variables or hosting provider.

By default, if NuxtHub cannot detect a driver, files are stored locally in the .data/blob directory.

To set the storage directory, you can set the dir option.

nuxt.config.ts
export default defineNuxtConfig({
  hub: {
    blob: {
      driver: 'fs',
      dir: '.data/my-blob-directory' // Defaults to `.data/blob`
    }
  }
})
The local filesystem driver is not suitable for production environments.

Upload a file

To upload a file, you can use the blob.put() method.

import { blob } from 'hub:blob'

const file = await blob.put('avatars/user-1.png', imageData)
Learn how to upload files with validation and progress tracking.

Driver options

You can set a custom driver by providing a configuration object to blob.

nuxt.config.ts
export default defineNuxtConfig({
  hub: {
    blob: {
      driver: 'fs',
      dir: '.data/blob'
    }
  },
  // or overwrite only in production
  $production: {
    hub: {
      blob: {
        driver: 'vercel-blob'
      }
    }
  }
})

Available drivers:

export default defineNuxtConfig({
  hub: {
    blob: {
      driver: 'fs',
      dir: '.data/files' // defaults to '.data/blob'
    }
  }
})