Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions alchemy-web/src/content/docs/providers/vercel/storage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
title: Storage
description: Create and manage Vercel Storage (Blob) with Alchemy
---

Create and manage Vercel Storage. Blob Storage is currently supported.

## Authentication

You can authenticate with Vercel in one of two ways:

1. Set `VERCEL_ACCESS_TOKEN` in your `.env` file
2. Pass `accessToken` directly in your resource configuration

## Examples

### With `accessToken`

```ts
const storage = await Storage("my-storage", {
accessToken: alchemy.secret(process.env.VERCEL_ACCESS_TOKEN),
name: "my-storage",
region: "iad1",
team: "team_abc123",
type: "blob",
});
```

### Minimal

```ts
const storage = await Storage("my-storage", {
name: "my-storage",
region: "cdg1",
team: "team_abc123",
type: "blob",
});
```

### Connect projects

Automatically connect projects and create environment variable bindings.

```ts
const storage = await Storage("my-storage", {
name: "my-storage",
projects: [
{
projectId: "prj_123",
envVarEnvironments: ["production", "preview"],
envVarPrefix: "MY_STORAGE_",
},
],
region: "iad1",
team: "team_abc123",
type: "blob",
});
```

### Update connections

Updating `projects` will add, remove, or re-create connections as needed. Changing `name`, `region`, `team`, or `type` will replace the Storage resource.

```ts
const storage = await Storage("my-storage", {
name: "my-storage",
projects: [
{
projectId: "prj_456",
envVarEnvironments: ["production"],
envVarPrefix: "BLOB_",
},
],
region: "iad1",
team: "team_abc123",
type: "blob",
});
```

## Props

- **name**: Optional display name for the storage. Defaults to the resource id
- **region**: One of Vercel regions (e.g. `"iad1"`, `"cdg1"`)
- **team**: Team id or a `VercelTeam` object
- **type**: Storage type. Currently only `"blob"`
- **projects**: Optional list of project connections with `projectId`, `envVarEnvironments`, and optional `envVarPrefix`

## Notes

- When replacing storage (changing `name`, `region`, `team`, or `type`), the old storage is deleted and a new one created
- Project connections are reconciled during updates: new ones are created, removed ones are disconnected, and changed ones are re-created
1 change: 1 addition & 0 deletions alchemy/src/vercel/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./api.ts";
export * from "./project-domain.ts";
export * from "./project.ts";
export * from "./storage.ts";
54 changes: 3 additions & 51 deletions alchemy/src/vercel/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { Resource } from "../resource.ts";
import { isSecret, type Secret } from "../secret.ts";
import { logger } from "../util/logger.ts";
import { createVercelApi, type VercelApi } from "./api.ts";

type TargetEnvironment = "production" | "preview" | "development";
import type { VercelEnvironments, VercelFrameworks } from "./vercel.types.ts";

export type EnvironmentVariable = {
/**
Expand All @@ -15,7 +14,7 @@ export type EnvironmentVariable = {
/**
* The target environment
*/
target: TargetEnvironment[];
target: VercelEnvironments;

/**
* The Git branch
Expand Down Expand Up @@ -82,54 +81,7 @@ export interface ProjectProps {
/**
* The framework that is being used for this project. When `null` is used no framework is selected
*/
framework?:
| "blitzjs"
| "nextjs"
| "gatsby"
| "remix"
| "react-router"
| "astro"
| "hexo"
| "eleventy"
| "docusaurus-2"
| "docusaurus"
| "preact"
| "solidstart-1"
| "solidstart"
| "dojo"
| "ember"
| "vue"
| "scully"
| "ionic-angular"
| "angular"
| "polymer"
| "svelte"
| "sveltekit"
| "sveltekit-1"
| "ionic-react"
| "create-react-app"
| "gridsome"
| "umijs"
| "sapper"
| "saber"
| "stencil"
| "nuxtjs"
| "redwoodjs"
| "hugo"
| "jekyll"
| "brunch"
| "middleman"
| "zola"
| "hydrogen"
| "vite"
| "vitepress"
| "vuepress"
| "parcel"
| "fasthtml"
| "sanity-v3"
| "sanity"
| "storybook"
| (string & {});
framework?: VercelFrameworks;

/**
* The Git Repository that will be connected to the project. When this is defined, any pushes to the specified connected Git Repository will be automatically deployed
Expand Down
Loading