DeployKit

Setup

Connect deploykit to Vercel.

Install

Follow the installation guide to install the alpha packages, then configure the provider below.

Add credentials

Create a token at vercel.com/account/tokens, scoped to the team that will own the projects.

.env
VERCEL_TOKEN=...
# Only if the token isn't already scoped to your team:
VERCEL_TEAM_ID=team_...

VERCEL_API_KEY is also accepted in place of VERCEL_TOKEN.

Create the client

src/deploykit.ts
import { Layer } from "effect"
import { NodeFileSystem } from "@effect/platform-node"
import * as Vercel from "@deploykit/vercel"

// Reads VERCEL_TOKEN and VERCEL_TEAM_ID from the environment.
export const DeploykitLive = Vercel.layerConfig().pipe(Layer.provide(NodeFileSystem.layer))

To pass options, use layer instead:

export const DeploykitLive = Vercel.layer({
  token,
  teamId,
  uploadThrottle: "balanced",
  memoryBudgetBytes: 512 * 1024 * 1024
}).pipe(Layer.provide(NodeFileSystem.layer))

Client options

OptionDefaultWhat it does
tokenrequiredVercel API token
teamIdnoneTeam to act for
uploadThrottlenoneUpload rate limit shared by every deploy. See Uploads
retry{ attempts: 4 }Retries for reads and uploads. See Errors
timeoutMs30000Time limit per HTTP operation, including retries
fetchglobal fetchCustom HTTP transport
memoryBudgetBytes, stagingBudgetBytes, maxFileBytessee LimitsShared memory and disk caps
onEventnoneTelemetry callback (Promise API). See Telemetry

What to deploy

A Build Output API tree. Paths in the artifact start with .vercel/output/:

.vercel/output/config.json                  routes, headers, redirects
.vercel/output/static/index.html            static files
.vercel/output/functions/api/hello.func/    serverless functions

Vercel won't build anything for you. Run your framework's build first: Next.js, Astro, SvelteKit, Nuxt and others can all output this format, often via vercel build. Then deploy the result:

await deploykit.deployDirectory(appId, "./my-app") // the folder that contains .vercel/output

Generated files go under .vercel/output/static/. Either write them into the folder before deploying, or add them in memory with Artifact.add at a path like .vercel/output/static/config.json.

Only put deployment content in the directory. Everything in it is uploaded, including dotfiles and anything like a .env file.

Deploy options

On top of the core options:

OptionDefaultWhat it does
activation"automatic""deferred" stages a production deploy without sending traffic to it. See Activation
operationIdnoneYour id for this attempt, to recover a lost response. Letters, digits, _, ., -; up to 128
metanoneKey-value strings attached to the deployment
uploadConcurrency8Files uploaded at once, 1 to 32. See Uploads
uploadOrder"manifest""largest-first" starts big files first
uploadRounds3Times to re-upload files Vercel still reports missing, 0 to 10

activation: "deferred" with target: "preview" is rejected: only production deploys can be staged.

Separate coordinator and worker

If one service manages projects and another uploads files, the coordinator only needs the control plane. @deploykit/vercel/control has no upload code and can be bundled for the browser or an edge runtime:

coordinator.ts
import { makeVercelClient, makeVercelControl } from "@deploykit/vercel/control"

const control = makeVercelControl(makeVercelClient({ token }))

// control.createApp, getDeployment, activateDeployment, ... all return Effects

It has every method except deploy. Keep @deploykit/vercel (or @deploykit/node) in the worker.

Last updated on

On this page