框架预设支持 #
框架概览 #
Vercel 原生支持多种前端框架:
text
┌─────────────────────────────────────────┐
│ Vercel 支持的框架 │
├─────────────────────────────────────────┤
│ React 生态 → Next.js, CRA, Remix │
│ Vue 生态 → Nuxt, Vue CLI │
│ Angular → Angular CLI │
│ Svelte → SvelteKit │
│ 静态站点 → Hugo, Jekyll, etc. │
│ 其他 → Astro, Gatsby, etc. │
└─────────────────────────────────────────┘
Next.js #
特性支持 #
| 特性 | 支持情况 |
|---|---|
| 自动静态优化 | ✅ |
| 服务端渲染 | ✅ |
| API 路由 | ✅ |
| 图片优化 | ✅ |
| 增量静态再生 | ✅ |
| 边缘函数 | ✅ |
项目结构 #
text
nextjs-app/
├── app/ # App Router (Next.js 13+)
│ ├── layout.tsx
│ ├── page.tsx
│ └── api/
│ └── route.ts
├── pages/ # Pages Router
│ ├── _app.tsx
│ ├── index.tsx
│ └── api/
│ └── hello.ts
├── public/
├── next.config.js
└── package.json
next.config.js #
javascript
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'standalone',
images: {
domains: ['example.com'],
},
experimental: {
serverActions: true,
},
}
module.exports = nextConfig
部署配置 #
json
{
"framework": "nextjs",
"buildCommand": "next build",
"outputDirectory": ".next"
}
输出模式 #
text
┌─────────────────────────────────────────┐
│ Next.js 输出模式 │
├─────────────────────────────────────────┤
│ 默认 → 服务端渲染 + 静态生成 │
│ standalone → 独立部署包 │
│ export → 纯静态导出 │
└─────────────────────────────────────────┘
React (Create React App) #
项目结构 #
text
cra-app/
├── public/
│ └── index.html
├── src/
│ ├── App.jsx
│ └── index.js
├── package.json
└── vercel.json
部署配置 #
json
{
"framework": "create-react-app",
"buildCommand": "react-scripts build",
"outputDirectory": "build"
}
路由配置 #
json
{
"rewrites": [
{ "source": "/(.*)", "destination": "/index.html" }
]
}
Vue.js #
Vue CLI 项目 #
text
vue-app/
├── public/
├── src/
│ ├── App.vue
│ └── main.js
├── vue.config.js
└── package.json
部署配置:
json
{
"framework": "vue",
"buildCommand": "vue-cli-service build",
"outputDirectory": "dist"
}
vue.config.js:
javascript
module.exports = {
publicPath: process.env.NODE_ENV === 'production' ? '/' : '/',
outputDir: 'dist',
}
Vite + Vue #
text
vite-vue-app/
├── src/
│ ├── App.vue
│ └── main.js
├── index.html
├── vite.config.js
└── package.json
部署配置:
json
{
"framework": "vue",
"buildCommand": "vite build",
"outputDirectory": "dist"
}
Nuxt.js #
项目结构 #
text
nuxt-app/
├── pages/
│ └── index.vue
├── components/
├── server/
│ └── api/
├── nuxt.config.ts
└── package.json
nuxt.config.ts #
typescript
export default defineNuxtConfig({
ssr: true,
nitro: {
preset: 'vercel'
}
})
部署配置 #
json
{
"framework": "nuxtjs",
"buildCommand": "nuxt build",
"outputDirectory": ".output"
}
渲染模式 #
text
┌─────────────────────────────────────────┐
│ Nuxt 渲染模式 │
├─────────────────────────────────────────┤
│ SSR → 服务端渲染(默认) │
│ SSG → 静态生成(nitro: preset: vercel-static)
│ SPA → 客户端渲染 │
└─────────────────────────────────────────┘
Angular #
项目结构 #
text
angular-app/
├── src/
│ ├── app/
│ ├── assets/
│ └── index.html
├── angular.json
└── package.json
angular.json #
json
{
"projects": {
"angular-app": {
"architect": {
"build": {
"options": {
"outputPath": "dist/angular-app"
}
}
}
}
}
}
部署配置 #
json
{
"framework": "angular",
"buildCommand": "ng build",
"outputDirectory": "dist/angular-app"
}
路由配置 #
json
{
"rewrites": [
{ "source": "/(.*)", "destination": "/index.html" }
]
}
SvelteKit #
项目结构 #
text
sveltekit-app/
├── src/
│ ├── routes/
│ │ └── +page.svelte
│ └── app.html
├── svelte.config.js
└── package.json
svelte.config.js #
javascript
import adapter from '@sveltejs/adapter-vercel'
export default {
kit: {
adapter: adapter({
runtime: 'edge'
})
}
}
部署配置 #
json
{
"framework": "sveltekit",
"buildCommand": "vite build",
"outputDirectory": ".svelte-kit"
}
Astro #
项目结构 #
text
astro-app/
├── src/
│ ├── pages/
│ │ └── index.astro
│ └── components/
├── astro.config.mjs
└── package.json
astro.config.mjs #
javascript
import { defineConfig } from 'astro/config'
import vercel from '@astrojs/vercel'
export default defineConfig({
output: 'server',
adapter: vercel()
})
部署配置 #
json
{
"framework": "astro",
"buildCommand": "astro build",
"outputDirectory": "dist"
}
输出模式 #
text
┌─────────────────────────────────────────┐
│ Astro 输出模式 │
├─────────────────────────────────────────┤
│ static → 纯静态站点 │
│ server → 服务端渲染 │
│ hybrid → 混合渲染 │
└─────────────────────────────────────────┘
Remix #
项目结构 #
text
remix-app/
├── app/
│ ├── routes/
│ ├── root.tsx
│ └── entry.client.tsx
├── remix.config.js
└── package.json
remix.config.js #
javascript
module.exports = {
ignoredRouteFiles: ['**/.*'],
serverAdapter: () => {
return '@vercel/remix'
}
}
部署配置 #
json
{
"framework": "remix",
"buildCommand": "remix build",
"outputDirectory": "public"
}
Gatsby #
项目结构 #
text
gatsby-app/
├── src/
│ ├── pages/
│ └── components/
├── gatsby-config.js
└── package.json
部署配置 #
json
{
"framework": "gatsby",
"buildCommand": "gatsby build",
"outputDirectory": "public"
}
静态站点生成器 #
Hugo #
text
hugo-site/
├── content/
├── layouts/
├── static/
└── config.toml
部署配置:
json
{
"buildCommand": "hugo",
"outputDirectory": "public"
}
Jekyll #
text
jekyll-site/
├── _posts/
├── _layouts/
├── _config.yml
└── index.html
部署配置:
json
{
"buildCommand": "jekyll build",
"outputDirectory": "_site"
}
Hexo #
text
hexo-site/
├── source/
├── themes/
├── _config.yml
└── package.json
部署配置:
json
{
"buildCommand": "hexo generate",
"outputDirectory": "public"
}
框架对比表 #
| 框架 | SSR | SSG | API | 边缘函数 | 推荐场景 |
|---|---|---|---|---|---|
| Next.js | ✅ | ✅ | ✅ | ✅ | 全栈应用 |
| Nuxt.js | ✅ | ✅ | ✅ | ✅ | Vue 全栈 |
| SvelteKit | ✅ | ✅ | ✅ | ✅ | 轻量全栈 |
| Astro | ✅ | ✅ | ✅ | ✅ | 内容站点 |
| Remix | ✅ | ❌ | ✅ | ✅ | 全栈应用 |
| Gatsby | ❌ | ✅ | ❌ | ❌ | 静态站点 |
| CRA | ❌ | ✅ | ❌ | ❌ | SPA |
| Vue CLI | ❌ | ✅ | ❌ | ❌ | SPA |
| Angular | ❌ | ✅ | ❌ | ❌ | 企业 SPA |
自定义框架 #
如果 Vercel 不支持你的框架,可以手动配置:
json
{
"buildCommand": "your-build-command",
"outputDirectory": "your-output-dir",
"installCommand": "npm install"
}
下一步 #
了解框架预设后,接下来学习 环境变量管理 掌握环境配置!
最后更新:2026-03-28