Skip to content

Latest commit

History

History
55 lines (41 loc) 路 1.75 KB

netlify-blobs.md

File metadata and controls

55 lines (41 loc) 路 1.75 KB

Netlify Blobs

Store data in a Netlify Blobs store. This is supported in both edge and Node.js runtimes, as well at during builds.

::alert{type="warning"} Netlify Blobs are in beta. ::

import { createStorage } from "unstorage";
import netlifyBlobsDriver from "unstorage/drivers/netlify-blobs";

const storage = createStorage({
  driver: netlifyBlobsDriver({
    name: "blob-store-name",
  }),
});

You can create a deploy-scoped store by settings deployScoped option to true. This will mean that the deploy only has access to its own store. The store is managed alongside the deploy, with the same deploy previews, deletes, and rollbacks.

import { createStorage } from "unstorage";
import netlifyBlobsDriver from "unstorage/drivers/netlify-blobs";

const storage = createStorage({
  driver: netlifyBlobsDriver({
    deployScoped: true,
  }),
});

To use, you will need to install @netlify/blobs as dependency or devDependency in your project:

{
  "devDependencies": {
    "@netlify/blobs": "*"
  }
}

Options:

  • name - The name of the store to use. It is created if needed. This is required except for deploy-scoped stores.
  • deployScoped - If set to true, the store is scoped to the deploy. This means that it is only available from that deploy, and will be deleted or rolled-back alongside it.
  • siteID - Required during builds, where it is available as constants.SITE_ID. At runtime this is set automatically.
  • token - Required during builds, where it is available as constants.NETLIFY_API_TOKEN. At runtime this is set automatically.

Advanced options:

These are not normally needed, but are available for advanced use cases or for use in unit tests.

  • apiURL
  • edgeURL