Skip to content

Convex.Projects reference

Source: packages/convex/src/DefaultEnvironmentVariables.ts

Default environment variables for a Convex project. New deployments start with them, which makes them the way to configure preview deployments that something other than Alchemy creates.

DefaultEnvironmentVariables: Setting Defaults

Section titled “DefaultEnvironmentVariables: Setting Defaults”
yield* Convex.DefaultEnvironmentVariables("Defaults", {
project,
deploymentTypes: ["preview"],
env: { API_URL: "https://staging.example.com" },
});

Source: packages/convex/src/Project.ts

A Convex project. It holds deployments, which hold the data.

Project with a generated name

const project = yield* Convex.Project("App");

Named project with tags

const project = yield* Convex.Project("App", {
name: "my-app",
tags: ["web"],
});

Remove the project on destroy

const project = yield* Convex.Project("App").pipe(RemovalPolicy.destroy());

Remove it in every stage but prod

const stack = yield* Stack;
const project = yield* Convex.Project("App").pipe(
RemovalPolicy.retain(stack.stage === "prod"),
);

Changing name renames the project in place. The slug stays unless you set slug, so URLs that use it keep working.

const project = yield* Convex.Project("App", {
name: "My App",
slug: "my-app",
});
const project = yield* Convex.Project("App");
const preview = yield* Convex.Deployment("Preview", { project, type: "preview" });

Convex allows two projects with one name, so a deploy looks for the name first. A project of that name without Alchemy’s tag fails with OwnedBySomeoneElse unless you deploy with --adopt.

Deleting a project deletes its deployments and their data, so a project with a prod deployment refuses until that deployment is gone.