Skip to main content

使用 Vercel 和 Prisma Postgres 进行即时应用部署

介绍

¥Introduction

本指南向你展示如何使用 Vercel 的 API 和集成的 Prisma Postgres 数据库实现即时应用部署。你将学习如何通过单个 API 调用以编程方式创建、部署和传输全栈应用。

¥This guide shows you how to implement instant app deployment using Vercel's API with integrated Prisma Postgres databases. You'll learn to programmatically create, deploy, and transfer full-stack applications with a single API call.

即时应用部署解决了 AI 编码平台、无代码工具和教育平台的一个关键问题:从生成的代码到可投入生产的应用。你无需用户手动设置托管基础设施,只需提供应用和数据库的一键部署即可。

¥Instant app deployment solves a critical problem for AI coding platforms, no-code tools, and educational platforms: getting from generated code to a live, production-ready application. Instead of requiring users to manually set up hosting infrastructure, you can offer one-click deployments with both application and database.

在本指南结束时,你将了解如何将 Vercel 的部署 API 与 Prisma Postgres 集成,从而为你的用户打造流畅的部署体验。

¥By the end of this guide, you'll understand how to integrate Vercel's deployment API with Prisma Postgres to create a smooth deployment experience for your users.

试用现场演示

¥Try the live demo

体验使用 我们的交互式演示 的即时部署流程。你可以部署并认领实际应用,以查看完整的运行过程。

¥Experience the instant deployment flow with our interactive demo. You can deploy and claim real applications to see the complete process in action.

Vercel App Deployment Demo

可用示例:

¥Available examples:

  • Next.js + Prisma:集成数据库的基本全栈应用

    ¥Next.js + Prisma: Basic full-stack application with database integration

  • Next.js + Prisma + Better-Auth:使用 Better-Auth 完成身份验证的应用

    ¥Next.js + Prisma + Better-Auth: Complete application with authentication using Better-Auth

演示功能:

¥Demo features:

  • 一键部署应用

    ¥Deploy applications with one click

  • 生成用于用户转移的声明代码

    ¥Generate claim codes for user transfer

  • 体验完整的声明流程

    ¥Experience the complete claiming flow

  • 查看源代码和实现细节

    ¥View source code and implementation details

访问 GitHub 仓库查看演示

¥Visit the GitHub repository for the demo.

适用对象

¥Who is this for

本指南专为以下开发者设计:

¥This guide is designed for developers building:

  • 基于 AI 的开发平台,可生成完整的应用并需要即时部署。

    ¥AI-powered development platforms that generate full applications and need instant deployment

  • 无需管理基础设施即可提供托管服务的无代码/低代码工具

    ¥No-code/low-code tools that want to offer hosting without managing infrastructure

  • 需要学生快速部署项目的教育平台

    ¥Educational platforms where students need to deploy projects quickly

  • 需要编程式部署功能的 CI/CD 系统

    ¥CI/CD systems that need programmatic deployment capabilities

  • 快速原型设计工具,将创意转化为已部署的应用

    ¥Rapid prototyping tools that transform ideas into deployed applications

核心概念

¥Core concepts

在实现部署流程之前,让我们先了解一下关键概念:

¥Before implementing the deployment flow, let's understand the key concepts:

Vercel 部署架构

¥Vercel deployment architecture

  • 项目:用于存放你的应用代码和配置的容器

    ¥Projects: Containers that hold your application code and configuration

  • 部署次数:将项目的特定实例部署到 Vercel 的边缘网络

    ¥Deployments: Specific instances of your project deployed to Vercel's edge network

  • 团队:拥有项目和管理计费的组织单位

    ¥Teams: Organizational units that own projects and manage billing

  • 集成:连接到你项目的第三方服务(例如 Prisma)

    ¥Integrations: Third-party services (like Prisma) that connect to your projects

Prisma 集成组件

¥Prisma integration components

  • 集成配置:你的团队与 Prisma 服务的连接

    ¥Integration configuration: Your team's connection to the Prisma service

  • 授权:代表你的团队创建资源的权限

    ¥Authorization: Permission to create resources on behalf of your team

  • 数据库存储:单个 Prisma Postgres 实例

    ¥Database stores: Individual Prisma Postgres instances

  • 资源连接:数据库和 Vercel 项目之间的链接

    ¥Resource connections: Links between databases and Vercel projects

API 端点概览

¥API endpoints overview

部署过程使用几个关键的 Vercel API 端点:

¥The deployment process uses several key Vercel API endpoints:

  • POST /v10/projects - 创建一个新的 Vercel 项目

    ¥POST /v10/projects - Create a new Vercel project

  • POST /v1/integrations/billing/authorization - 授权 Prisma 集成

    ¥POST /v1/integrations/billing/authorization - Authorize Prisma integration

  • POST /v1/storage/stores/integration - 创建 Prisma Postgres 数据库

    ¥POST /v1/storage/stores/integration - Create Prisma Postgres database

  • POST /v13/deployments - 部署应用代码

    ¥POST /v13/deployments - Deploy application code

  • POST /v9/projects/{id}/transfer-request - 生成用于用户转移的声明代码

    ¥POST /v9/projects/{id}/transfer-request - Generate claim code for user transfer

所需的 API 密钥和环境变量

¥Required API keys and environment variables

联系我们获取用于创建数据库的高级合作伙伴级别访问权限

默认情况下,每个新合作伙伴都使用我们的免费方案,每个账户最多可创建 5 个数据库,因此,如果你正在尝试使用此 API 并需要更高的数据库创建限制(我们怀疑大多数人都会遇到这种情况),请使用 联系我们 来获得合作伙伴级别的访问权限。

¥By default, every new partner is on our free plan which limited to 5 dbs per account, so if you are trying out this API and need higher db creation limits (which we suspect that most of you will), then please contact us to get partner level access.

Vercel 访问令牌

¥Vercel access token

你用于 Vercel API 调用的主要身份验证令牌。

¥Your primary authentication token for Vercel API calls.

获取方式:

¥Where to get it:

  1. 前往 Vercel 账户设置

    ¥Go to Vercel Account Settings

  2. 点击“创建令牌”

    ¥Click Create Token

  3. 命名(例如,"即时部署 API")

    ¥Name it (e.g., "Instant Deployment API")

  4. 将范围设置为你的团队(而非个人账户)

    ¥Set scope to your team (not personal account)

  5. 立即复制令牌(你将不会再看到它)

    ¥Copy the token immediately (you won't see it again)

提示

你需要 Vercel 团队的 "所有者" 级访问权限,以确保 ACCESS_TOKEN 适用于所有 API 调用。

¥You need "Owner" level access to the Vercel team to ensure the ACCESS_TOKEN works for all the API calls.

ACCESS_TOKEN="vercel_token_here"
信用卡要求

Vercel 要求将信用卡绑定到你的账户(即使是 Hobby 计划)才能使用部署 API。在继续操作之前,请确保在你的 Vercel 账户设置中添加付款信息。

¥Vercel requires a credit card to be attached to your account (even on the Hobby plan) to use the deployment APIs. Make sure to add payment information in your Vercel account settings before proceeding.

团队 ID

¥Team ID

你的 Vercel 团队用于 API 请求的标识符。

¥Your Vercel team identifier for API requests.

获取方式:

¥Where to get it:

  1. 前往 Vercel 仪表板

    ¥Go to Vercel Dashboard

  2. 切换到你的团队账户(而非个人账户)

    ¥Switch to your Team (not personal account)

  3. 前往团队设置

    ¥Go to Team Settings

  4. 复制顶部显示的团队 ID(格式:team_abc123xyz

    ¥Copy the Team ID displayed at the top (format: team_abc123xyz)

TEAM_ID="team_abc123xyz"

Prisma 集成配置 ID

¥Prisma integration config ID

你团队的 Prisma 集成配置标识符。

¥Your team's Prisma integration configuration identifier.

获取方式:

¥Where to get it:

  1. 在 Vercel 仪表板中,转到你的团队

    ¥In Vercel Dashboard, go to your Team

  2. 点击“集成”选项卡

    ¥Click Integrations tab

  3. 找到 Prisma 并点击“管理”(如有需要,请先安装)

    ¥Find Prisma and click Manage (install it first if needed)

  4. 在浏览器 URL 中,复制配置 ID:https://vercel.com/teams/your-team/integrations/icfg_abc123xyz

    ¥In the browser URL, copy the config ID: https://vercel.com/teams/your-team/integrations/icfg_abc123xyz

  5. 复制 icfg_abc123xyz 部分

    ¥Copy the icfg_abc123xyz part

INTEGRATION_CONFIG_ID="icfg_abc123xyz"

Prisma 产品 ID

¥Prisma Product ID

Prisma 产品 ID 用于在 Vercel API 中识别 Prisma 集成,它是一个常量值:iap_yVdbiKqs5fLkYDABprisma-postgres

¥The Prisma Product ID is used to identify the Prisma integration in the Vercel API and it's a constant value of: iap_yVdbiKqs5fLkYDAB or prisma-postgres.

PRISMA_PRODUCT_ID="iap_yVdbiKqs5fLkYDAB"

Prisma Postgres 区域

¥Prisma Postgres region

Prisma Postgres 数据库将部署到的区域。选择靠近你用户的区域以获得最佳性能。

¥The region where your Prisma Postgres database will be deployed. Choose a region close to your users for optimal performance.

可用区域:

¥Available regions:

  • iad1 - 美国东部(弗吉尼亚)

    ¥iad1 - US East (Virginia)

  • fra1 - 欧洲(法兰克福)

    ¥fra1 - Europe (Frankfurt)

  • sfo1 - 美国西部(旧金山)

    ¥sfo1 - US West (San Francisco)

  • sin1 - 亚太地区(新加坡)

    ¥sin1 - Asia Pacific (Singapore)

  • hnd1 - 亚太地区(东京)

    ¥hnd1 - Asia Pacific (Tokyo)

  • cdg1 - 欧洲(巴黎)

    ¥cdg1 - Europe (Paris)

PRISMA_POSTGRES_REGION="iad1"

查看 支持的 Prisma Postgres 区域 及其对应 Vercel 区域代码 的完整列表。

¥See the complete list of supported Prisma Postgres regions and their corresponding Vercel region codes.

Prisma 计费方案

¥Prisma billing plan

计费方案决定了数据库的限制和功能。可用方案:

¥The billing plan determines database limits and features. Available plans:

  • free - 仅限 5 个数据库,适合开发

    ¥free - Limited to 5 databases, suitable for development

  • pro - 连接池和缓存的更高限制

    ¥pro - Higher limits with connection pooling and caching

  • business - 优先支持的企业功能

    ¥business - Enterprise features with priority support

  • enterprise - 自定义限制和专属支持

    ¥enterprise - Custom limits and dedicated support

  • partnerEntry - 具有高数据库限制的合作伙伴级别访问权限

    ¥partnerEntry - Partner-level access with high database limits

PRISMA_BILLING_PLAN="partnerEntry"
建议合作伙伴访问

对于需要多个数据库的生产部署,我们推荐使用 partnerEntry 方案,该方案提供更高的数据库创建限制。申请合作伙伴访问权限 解锁这些功能。

¥For production deployments requiring multiple databases, we recommend the partnerEntry plan which provides higher database creation limits. Apply for partner access to unlock these capabilities.

完整部署示例

¥Complete deployment example

以下代码片段展示了完整的部署流程:

¥The code snippet below shows the complete deployment flow:

const CONFIG = {
ACCESS_TOKEN: process.env.ACCESS_TOKEN,
TEAM_ID: process.env.TEAM_ID,
INTEGRATION_CONFIG_ID: process.env.INTEGRATION_CONFIG_ID,
PRISMA_PRODUCT_ID: process.env.PRISMA_PRODUCT_ID || "iap_yVdbiKqs5fLkYDAB", // or can be `prisma-postgres`
PRISMA_POSTGRES_REGION: process.env.PRISMA_POSTGRES_REGION || "iad1",
PRISMA_BILLING_PLAN: process.env.PRISMA_BILLING_PLAN || "partnerEntry",
VERCEL_API_URL: "https://api.vercel.com",
};

async function deployApp() {
console.log("🚀 Starting instant deployment...");

// 1. Create project
const project = await createProject();

// 2. Authorize Prisma integration
const auth = await createPrismaAuthorization();

// 3. Create database
const database = await createPrismaDatabase(
project.name,
auth.id,
auth.configId
);

// 4. Connect database to project
await connectDatabaseToProject(project.id, database.id, auth.configId);

// 5. Deploy application (assumes files already uploaded)
const deployment = await deployApplication(project.name, fileSha);

// 6. Generate claim code
const transfer = await createProjectTransfer(project.id);

console.log("🎉 Deployment completed!");
console.log(`Live URL: https://${deployment.url}`);
console.log(`Claim URL: ${transfer.claimUrl}`);

return {
projectId: project.id,
deploymentUrl: `https://${deployment.url}`,
claimCode: transfer.code,
claimUrl: transfer.claimUrl,
};
}

分步部署流程

¥Step-by-step deployment process

上面的完整示例演示了整个部署过程。现在让我们详细分解每个步骤。

¥The complete example above demonstrates the entire deployment process. Now let's break down each step in detail.

步骤 1:创建 Vercel 项目

¥Step 1: Create a Vercel project

每次部署都始于创建项目容器。

¥Every deployment starts with creating a project container.

async function createProject(): Promise<{ id: string; name: string }> {
const projectName = `demo-project-${Date.now()}`;

const response = await fetch(
`${CONFIG.VERCEL_API_URL}/v10/projects?teamId=${CONFIG.TEAM_ID}`,
{
method: "POST",
headers: {
Authorization: `Bearer ${CONFIG.ACCESS_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ name: projectName }),
}
);

const project = await response.json();
console.log(`✅ Project created: ${project.name} (${project.id})`);

return { id: project.id, name: project.name };
}

关键参数:

¥Key parameters:

  • name:唯一项目标识符(自动生成,带有时间戳)

    ¥name: Unique project identifier (auto-generated with timestamp)

  • teamId:你的团队 ID,用于正确管理项目所有权

    ¥teamId: Your team ID for proper project ownership

Vercel 项目 API 文档 中了解更多信息。

¥Learn more in the Vercel Projects API documentation.

第 2 步:授权 Prisma 集成

¥Step 2: Authorize Prisma integration

在创建数据库之前,你需要获得代表团队使用 Prisma 的授权。

¥Before creating databases, you need authorization to use Prisma on behalf of your team.

async function createPrismaAuthorization(): Promise<{
id: string;
configId: string;
}> {
const response = await fetch(
`${CONFIG.VERCEL_API_URL}/v1/integrations/billing/authorization?teamId=${CONFIG.TEAM_ID}`,
{
method: "POST",
headers: {
Authorization: `Bearer ${CONFIG.ACCESS_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
integrationIdOrSlug: "prisma",
productId: CONFIG.PRISMA_PRODUCT_ID,
billingPlanId: CONFIG.PRISMA_BILLING_PLAN,
metadata: JSON.stringify({ region: CONFIG.PRISMA_POSTGRES_REGION }),
integrationConfigurationId: CONFIG.INTEGRATION_CONFIG_ID,
}),
}
);

const authData = await response.json();

return {
id: authData.authorization.id,
configId: authData.authorization.integrationConfigurationId,
};
}

关键参数:

¥Key parameters:

  • billingPlanId:计费方案(建议在生产环境中使用 "partnerEntry")

    ¥billingPlanId: Billing plan ("partnerEntry" recommended for production)

  • region:用于实现最佳性能的数据库区域

    ¥region: Database region for optimal performance

  • metadata:包含区域和其他配置的 JSON 字符串

    ¥metadata: JSON string containing region and other configuration

Vercel 集成 API 文档 中了解更多信息。

¥Learn more in the Vercel Integrations API documentation.

步骤 3:配置 Prisma Postgres 数据库

¥Step 3: Provision Prisma Postgres database

创建一个具有自动连接池和缓存的新数据库实例。

¥Create a new database instance with automatic connection pooling and caching.

async function createPrismaDatabase(
projectName: string,
authId: string,
configId: string
): Promise<{ id: string; }> {
const response = await fetch(
`${CONFIG.VERCEL_API_URL}/v1/storage/stores/integration?teamId=${CONFIG.TEAM_ID}`,
{
method: "POST",
headers: {
Authorization: `Bearer ${CONFIG.ACCESS_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
metadata: { region: CONFIG.PRISMA_POSTGRES_REGION },
billingPlanId: CONFIG.PRISMA_BILLING_PLAN,
name: `postgres-${projectName}`,
integrationConfigurationId: configId,
integrationProductIdOrSlug: CONFIG.PRISMA_PRODUCT_ID,
authorizationId: authId,
source: "marketplace",
}),
}
);

const storageData = await response.json();

return {
id: storageData.store.id
};
}

关键参数:

¥Key parameters:

  • name:数据库标识符(通常与项目名称匹配)

    ¥name: Database identifier (typically matches project name)

  • source:"marketplace" 用于 Vercel 市场集成

    ¥source: "marketplace" for Vercel marketplace integrations

  • billingPlanId:确定功能和限制的计费方案

    ¥billingPlanId: Billing plan that determines features and limits

Vercel 存储 API 文档 中了解更多信息。

¥Learn more in the Vercel Storage API documentation.

步骤 4:将数据库连接到项目

¥Step 4: Connect database to project

将数据库链接到你的 Vercel 项目以进行自动环境变量注入。

¥Link the database to your Vercel project for automatic environment variable injection.

async function connectDatabaseToProject(
projectId: string,
storeId: string,
configId: string
): Promise<void> {
await fetch(
`${CONFIG.VERCEL_API_URL}/v1/integrations/installations/${configId}/products/${CONFIG.PRISMA_PRODUCT_ID}/resources/${storeId}/connections?teamId=${CONFIG.TEAM_ID}`,
{
method: "POST",
headers: {
Authorization: `Bearer ${CONFIG.ACCESS_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ projectId }),
}
);

console.log("✅ Database connected to project");
}

此连接会自动将 DATABASE_URL 和其他环境变量添加到你的项目中。

¥This connection automatically adds DATABASE_URL and other environment variables to your project.

Vercel 集成资源文档 中了解更多信息。

¥Learn more in the Vercel Integration Resources documentation.

步骤 5:部署应用

¥Step 5: Deploy the application

将你的应用代码部署到 Vercel。

¥Deploy your application code to Vercel.

async function deployApplication(
projectName: string,
fileSha: string
): Promise<{ id: string; url: string }> {
const response = await fetch(
`${CONFIG.VERCEL_API_URL}/v13/deployments?teamId=${CONFIG.TEAM_ID}`,
{
method: "POST",
headers: {
Authorization: `Bearer ${CONFIG.ACCESS_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
files: [{ file: ".vercel/source.tgz", sha: fileSha }],
name: `deployment-${Date.now()}`,
projectSettings: { framework: "nextjs" },
project: projectName,
}),
}
);

const deploymentData = await response.json();

return {
id: deploymentData.id,
url: deploymentData.alias?.[0] || deploymentData.url,
};
}

关键参数:

¥Key parameters:

  • files:已上传文件数组(需要事先以 tgz 格式上传文件)

    ¥files: Array of uploaded files (requires prior file upload in tgz format)

  • framework:"nextjs"、"react"、"vue" 等用于自动配置

    ¥framework: "nextjs", "react", "vue", etc. for automatic configuration

  • projectSettings:特定于框架的构建和运行时设置

    ¥projectSettings: Framework-specific build and runtime settings

Vercel 部署 API 文档 中了解更多信息或参阅 Vercel API 参考

¥Learn more in the Vercel Deployments API documentation or see the Vercel API Reference.

步骤 6:生成用于用户转移的声明代码

¥Step 6: Generate claim code for user transfer

创建一个允许用户声明已部署项目所有权的转移代码。

¥Create a transfer code that allows users to claim ownership of the deployed project.

async function createProjectTransfer(
projectId: string
): Promise<{ code: string; claimUrl: string }> {
const response = await fetch(
`${CONFIG.VERCEL_API_URL}/v9/projects/${projectId}/transfer-request?teamId=${CONFIG.TEAM_ID}`,
{
method: "POST",
headers: {
Authorization: `Bearer ${CONFIG.ACCESS_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({}),
}
);

const transferData = await response.json();
const claimUrl = `https://vercel.com/claim-deployment?code=${transferData.code}&returnUrl=https://myapp.com/dashboard/projects`;

return {
code: transferData.code,
claimUrl,
};
}

关键细节:

¥Key details:

  • 转移代码有效期为 24 小时

    ¥Transfer codes are valid for 24 hours

  • 用户可以在其 Vercel 账户中将项目声明给任何团队

    ¥Users can claim projects to any team in their Vercel account

  • 如果声明 URL 无效或已过期,returnUrl 会将用户重定向到特定页面。

    ¥The returnUrl redirects users to a specific page if the claim URL is invalid or expired

Vercel 声明部署文档 中了解更多信息。

¥Learn more in the Vercel Claim Deployments documentation.

用户认领流程

¥User claim flow

部署后,用户可以通过安全的转移流程声明所有权:

¥After deployment, users can claim ownership through a secure transfer process:

声明的工作原理

¥How claiming works

  1. 用户接收声明 URL:你的平台提供生成的声明 URL

    ¥User receives claim URL: Your platform provides the generated claim URL

  2. 用户身份验证:如果未通过身份验证,Vercel 会提示登录

    ¥User authentication: Vercel prompts for login if not authenticated

  3. 团队选择:用户选择哪个 Vercel 团队拥有该项目

    ¥Team selection: User chooses which Vercel team should own the project

  4. 转移完成:将项目和数据库传输到用户选择的团队

    ¥Transfer completion: Project and database transfer to user's selected team

  5. 账单转账:用户的团队负责托管费用

    ¥Billing transfer: User's team becomes responsible for hosting costs

声明 URL 结构

¥Claim URL structure

https://vercel.com/claim-deployment?code=xxx&returnUrl=https://myapp.com/dashboard/projects

参数:

¥Parameters:

  • code:步骤 6 中的转移代码(有效期 24 小时)

    ¥code: The transfer code from Step 6 (valid 24 hours)

  • returnUrl:如果声明 URL 无效或已过期,则将用户重定向到特定页面

    ¥returnUrl: Redirects users to a specific page if the claim URL is invalid or expired

传输内容

¥What gets transferred

当用户申请部署时,他们会收到:

¥When a user claims a deployment, they receive:

  • 拥有所有源代码和配置的完整项目所有权

    ¥Full project ownership with all source code and configuration

  • 数据库所有权,包括所有数据和连接字符串

    ¥Database ownership including all data and connection strings

  • 为新团队自动更新环境变量

    ¥Environment variables automatically updated for the new team

  • 部署历史记录和构建日志

    ¥Deployment history and build logs

声明部署文档 中了解更多信息。

¥Learn more in the Claim Deployments documentation.

错误处理和最佳实践

¥Error handling and best practices

常见错误场景

¥Common error scenarios

async function handleApiErrors(response: Response, operation: string) {
if (!response.ok) {
const errorData = await response.text();

// Handle specific error cases
switch (response.status) {
case 401:
throw new Error(`Authentication failed: Check your ACCESS_TOKEN`);
case 403:
throw new Error(`Permission denied: Verify team access and scopes`);
case 429:
throw new Error(`Rate limit exceeded: Implement retry logic`);
case 404:
throw new Error(`Resource not found: Check IDs and configuration`);
default:
throw new Error(`${operation} failed: ${response.status} - ${errorData}`);
}
}
}

正确的错误处理可防止部署失败,并向用户提供清晰的调试信息。

¥Proper error handling prevents deployment failures and provides clear debugging information to your users.

速率限制注意事项

¥Rate limiting considerations

Vercel 对 API 端点强制执行速率限制。你可以实现指数退避来处理速率限制:

¥Vercel enforces rate limits on API endpoints. You can implement exponential backoff to handle rate limits:

async function apiCallWithRetry(url: string, options: RequestInit, maxRetries = 3) {
for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
const response = await fetch(url, options);

if (response.status === 429) {
const waitTime = Math.pow(2, attempt) * 1000; // Exponential backoff
await new Promise(resolve => setTimeout(resolve, waitTime));
continue;
}

return response;
} catch (error) {
if (attempt === maxRetries) throw error;
}
}
}

重试逻辑可确保你的部署服务在高流量期间保持可靠。

¥Retry logic ensures your deployment service remains reliable during high-traffic periods.

Vercel API 限制文档 中了解更多信息。

¥Learn more in the Vercel API Limits documentation.

安全最佳实践

¥Security best practices

  • 安全存储令牌:切勿在客户端代码中暴露 API 令牌

    ¥Store tokens securely: Never expose API tokens in client-side code

  • 验证输入:清理项目名称和用户提供的数据

    ¥Validate inputs: Sanitize project names and user-provided data

  • 监控使用情况:跟踪 API 调用以防止滥用

    ¥Monitor usage: Track API calls to prevent abuse

  • 实现超时:设置合理的请求超时以确保可靠性

    ¥Implement timeouts: Set reasonable request timeouts for reliability

这些做法可以保护你的集成免受常见安全漏洞的影响,并确保稳定运行。

¥These practices protect your integration from common security vulnerabilities and ensure stable operation.

生产环境注意事项

¥Production considerations

以下是部署服务的一些生产注意事项:

¥The following are some production considerations for your deployment service:

与现有平台集成

¥Integration with existing platforms

你可以将部署服务与现有平台集成,为你的用户提供流畅的体验:

¥You can integrate your deployment service with existing platforms to provide a smooth experience for your users:

// Example integration with an AI coding platform
class DeploymentService {
async deployGeneratedApp(code: string, userId: string) {
// 1. Package generated code
const packagedCode = await this.packageCode(code);

// 2. Deploy with Vercel + Prisma
const deployment = await this.deployApp(packagedCode);

// 3. Store deployment info
await this.storeDeployment(userId, deployment);

// 4. Notify user
await this.notifyUser(userId, deployment.claimUrl);

return deployment;
}
}

监控和分析

¥Monitoring and analytics

跟踪部署服务的关键指标:

¥Track key metrics for your deployment service:

  • 部署成功率:监控 API 故障和超时

    ¥Deployment success rate: Monitor API failures and timeouts

  • 索赔转化率:跟踪有多少用户认领了他们的部署

    ¥Claim conversion rate: Track how many users claim their deployments

  • 性能指标:衡量部署时间和用户体验

    ¥Performance metrics: Measure deployment time and user experience

  • 成本分析:监控 Vercel 和 Prisma 使用成本

    ¥Cost analysis: Monitor Vercel and Prisma usage costs

下一步

¥Next steps

现在,你了解了如何使用 Vercel 和 Prisma Postgres 进行即时应用部署,你可以:

¥Now that you understand instant app deployment with Vercel and Prisma Postgres, you can:

  • 集成到你的平台:为你现有的应用添加部署功能。

    ¥Integrate into your platform: Add deployment capabilities to your existing application

  • 自定义流程:根据你的具体用例和用户体验调整流程。

    ¥Customize the flow: Adapt the process for your specific use case and user experience

  • 扩展你的实现:使用适当的队列和错误处理来处理大容量部署

    ¥Scale your implementation: Handle high-volume deployments with proper queuing and error handling

  • 监控和优化:跟踪性能和用户采用率指标

    ¥Monitor and optimize: Track performance and user adoption metrics

其他资源

¥Additional resources

如有任何集成方面的问题或需要支持,请通过 Prisma 社区 DiscordVercel 支持 联系我们。

¥For questions or support with your integration, reach out through the Prisma Community Discord or Vercel Support.


Stay connected with Prisma

Continue your Prisma journey by connecting with our active community. Stay informed, get involved, and collaborate with other developers:

We genuinely value your involvement and look forward to having you as part of our community!