Skip to content

prisma/vercel-deployment-claim-demo

Repository files navigation

Claim deployments demo

This application demonstrates how to transfer a Vercel project from one account to another using the Claim Deployments feature.

The demo covers the entire process, including creating a project in the host team, initiating the transfer, and enabling users to claim the project for themselves. Projects are created with Next.js templates that include Prisma Postgres integration and optional Better Auth authentication.

Try it out at: https://app-deploy-demo.prisma.io/

Getting started

To set up the project, add the following environment variables to your .env.local file:

# Required for Vercel API access and project management
TEAM_ID=""
ACCESS_TOKEN=""
INTEGRATION_CONFIG_ID=""

# Required for automated cleanup cron job security
CRON_SECRET=""

# Configure these to match your Prisma setup
PRISMA_INTEGRATION_PRODUCT_ID="iap_yVdbiKqs5fLkYDAB"  # or "prisma-postgres"
DEFAULT_BILLING_PLAN_ID="business"  # Your actual Prisma plan
VERCEL_REGION="iad1"  # Prisma Postgres database region

# PostHog Analytics (optional)
NEXT_PUBLIC_POSTHOG_KEY=""
NEXT_PUBLIC_POSTHOG_HOST="https://us.i.posthog.com"

Required API keys and configuration

1. Team ID

Environment Variable: TEAM_ID

Where to get it:

  • Go to Vercel Dashboard
  • Switch to your Team (not personal account)
  • Go to Team Settings
  • The Team ID is displayed at the top of the settings page
  • It looks like: team_abc123xyz

2. Access token

Environment variable: ACCESS_TOKEN

⚠️ Important: The access token must be created by someone with an Owner role in the Vercel team.

Where to get it:

  • Go to the Tokens page in the Vercel Dashboard
  • Generate a new access token
  • Ensure that the token's scope matches the team where the projects will be transferred from
  • The token creator must have Owner permissions on the team

3. Prisma integration config ID

Environment variable: INTEGRATION_CONFIG_ID

Where to get it:

  • In Vercel Dashboard, go to your Team
  • Click Integrations tab
  • Find Prisma and click Configure (install it first if needed)
  • In the URL, you'll see the config ID: https://vercel.com/teams/your-team/integrations/icfg_abc123xyz
  • Copy the icfg_abc123xyz part

Example:

INTEGRATION_CONFIG_ID="icfg_abc123xyz"

Additional Required Configuration

These variables have default values but should be configured to match your Prisma setup:

4. Prisma Integration Product ID

Environment variable: PRISMA_INTEGRATION_PRODUCT_ID Default: "iap_yVdbiKqs5fLkYDAB"

Important: Set this to match your Prisma integration. Use "prisma-postgres" if that's what your integration uses.

5. Default Billing Plan ID

Environment variable: DEFAULT_BILLING_PLAN_ID Default: "business"

Important: This must match your actual Prisma billing plan.

To find your Prisma billing plan:

  1. Go to Vercel Dashboard → Your Team → "Integrations"
  2. Click on Prisma integration and then click on "Settings"
  3. Look for "Current Installation Level Plan" section
  4. Set DEFAULT_BILLING_PLAN_ID to the exact plan name shown (e.g., "business", "pro", "enterprise")

6. Cron Secret

Environment variable: CRON_SECRET

Important: This is required for securing the automated cleanup cron job endpoint.

Where to get it:

  • Generate a random string of at least 16 characters
  • You can use a password generator like 1Password
  • Set this same value in your Vercel project's environment variables

Example:

CRON_SECRET="your-secure-random-string-here"

7. Prisma Postgres Database Region

Environment variable: VERCEL_REGION Default: "iad1" (us-east-1, Washington, D.C., USA)

Important: This specifies the region for your Prisma Postgres database, not Vercel deployments. Choose the region closest to your users for optimal database performance.

Select a region from the Vercel regions list and set this value accordingly.

8. PostHog Analytics (Optional)

Environment variables: NEXT_PUBLIC_POSTHOG_KEY and NEXT_PUBLIC_POSTHOG_HOST

These are optional environment variables for analytics tracking. If you don't need analytics, you can leave these empty.

Running the development server

After setting up the environment variables, install dependencies:

pnpm install

Start the development server using your preferred package manager:

pnpm run dev

Once the server is running, open http://localhost:3000 in your browser to view the demo application.

Automated Cleanup

This application includes an automated cleanup system that runs twice daily (6 AM and 6 PM UTC) to remove temporary projects older than 12 hours.

How it works:

  1. Cron Job: Configured in vercel.json to run at 0 6,18 * * * (twice daily)
  2. API Endpoint: /api/cleanup-projects handles the cleanup logic
  3. Security: Protected by CRON_SECRET environment variable
  4. Cleanup Criteria:
    • Projects starting with "temp-project"
    • Older than 12 hours
    • Created from this repository

Manual Cleanup

You can also run cleanup manually using the script:

pnpm run clean:up

Or call the API endpoint directly (with proper authentication):

curl -X POST https://your-domain.vercel.app/api/cleanup-projects \
  -H "Authorization: Bearer your-cron-secret"

Releases

No releases published

Packages

No packages published

Languages