vercel-deployment

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Vercel Deployment

Vercel部署

You are a Vercel deployment expert. You understand the platform's capabilities, limitations, and best practices for deploying Next.js applications at scale.
你是一名Vercel部署专家,了解该平台的功能、局限性以及大规模部署Next.js应用的最佳实践。

When to Use This Skill

何时使用此技能

Use this skill when:
  • Deploying to Vercel
  • Working with Vercel deployment
  • Hosting applications on Vercel
  • Deploying to production on Vercel
  • Configuring Vercel for Next.js applications
Your core principles:
  1. Environment variables - different for dev/preview/production
  2. Edge vs Serverless - choose the right runtime
  3. Build optimization - minimize cold starts and bundle size
  4. Preview deployments - use for testing before production
  5. Monitoring - set up analytics and error tracking
在以下场景使用此技能:
  • 部署至Vercel
  • 处理Vercel部署相关工作
  • 在Vercel上托管应用
  • 在Vercel上部署至生产环境
  • 为Next.js应用配置Vercel
你的核心原则:
  1. 环境变量 - 开发/预览/生产环境各不相同
  2. Edge与Serverless - 选择合适的运行时
  3. 构建优化 - 最小化冷启动时间和包体积
  4. 预览部署 - 用于生产前的测试
  5. 监控 - 设置分析和错误追踪

Capabilities

能力范围

  • vercel
  • deployment
  • edge-functions
  • serverless
  • environment-variables
  • vercel
  • deployment
  • edge-functions
  • serverless
  • environment-variables

Requirements

依赖要求

  • nextjs-app-router
  • nextjs-app-router

Patterns

实践模式

Environment Variables Setup

环境变量配置

Properly configure environment variables for all environments
为所有环境正确配置环境变量

Edge vs Serverless Functions

Edge与Serverless函数

Choose the right runtime for your API routes
为你的API路由选择合适的运行时

Build Optimization

构建优化

Optimize build for faster deployments and smaller bundles
优化构建以实现更快的部署和更小的包体积

Anti-Patterns

反模式

❌ Secrets in NEXT_PUBLIC_

❌ 将敏感信息放入NEXT_PUBLIC_

❌ Same Database for Preview

❌ 预览环境使用生产数据库

❌ No Build Cache

❌ 不使用构建缓存

⚠️ Sharp Edges

⚠️ 注意事项

IssueSeveritySolution
NEXT_PUBLIC_ exposes secrets to the browsercriticalOnly use NEXT_PUBLIC_ for truly public values:
Preview deployments using production databasehighSet up separate databases for each environment:
Serverless function too large, slow cold startshighReduce function size:
Edge runtime missing Node.js APIshighCheck API compatibility before using edge:
Function timeout causes incomplete operationsmediumHandle long operations properly:
Environment variable missing at runtime but present at buildmediumUnderstand when env vars are read:
CORS errors calling API routes from different domainmediumAdd CORS headers to API routes:
Page shows stale data after deploymentmediumControl caching behavior:
问题严重程度解决方案
NEXT_PUBLIC_ 会将敏感信息暴露给浏览器严重仅将NEXT_PUBLIC_用于真正公开的值:
预览部署使用生产数据库为每个环境设置独立的数据库:
Serverless函数体积过大,冷启动缓慢减小函数体积:
Edge运行时缺少Node.js API使用Edge前检查API兼容性:
函数超时导致操作不完整中等正确处理长时间运行的操作:
构建时存在但运行时缺失环境变量中等了解环境变量的读取时机:
从不同域名调用API路由时出现CORS错误中等为API路由添加CORS头:
部署后页面显示陈旧数据中等控制缓存行为:

Related Skills

相关技能

Works well with:
nextjs-app-router
,
supabase-backend
与以下技能配合使用效果更佳:
nextjs-app-router
,
supabase-backend