@flightdev/adapter-vercel
v0.0.7
Published
Vercel adapter for Flight Framework - deploy to Vercel Edge/Serverless
Maintainers
Readme
@flightdev/adapter-vercel
Vercel deployment adapter for Flight Framework. Supports both Serverless and Edge runtimes.
Table of Contents
- Installation
- Quick Start
- Configuration
- Edge Runtime
- ISR (Incremental Static Regeneration)
- Build Output
- Deployment
- Environment Variables
- API Reference
- License
Installation
npm install @flightdev/adapter-vercelQuick Start
// flight.config.ts
import { defineConfig } from '@flightdev/core';
import vercel from '@flightdev/adapter-vercel';
export default defineConfig({
adapter: vercel(),
});Deploy:
npm run build
vercel --prodConfiguration
vercel({
// Node.js runtime version
runtime: 'nodejs20.x',
// Deployment regions
regions: ['iad1', 'sfo1', 'cdg1'],
// Function memory (MB)
memory: 1024,
// Max execution time (seconds)
maxDuration: 30,
// Split routes into separate functions
split: true,
// Enable ISR
isr: {
expiration: 60,
bypassToken: process.env.ISR_BYPASS_TOKEN,
},
// Images configuration
images: {
domains: ['example.com'],
sizes: [640, 750, 828, 1080, 1200],
},
});Edge Runtime
Deploy API routes to the edge for low latency:
// Per-route configuration
// src/routes/api/fast.get.ts
export const config = {
runtime: 'edge',
regions: ['iad1', 'sfo1', 'cdg1', 'hnd1'],
};
export async function GET(request: Request) {
return Response.json({ fast: true });
}Or configure globally:
vercel({
runtime: 'edge',
regions: ['iad1', 'sfo1'],
});ISR
Incremental Static Regeneration for dynamic content:
// flight.config.ts
vercel({
isr: {
expiration: 60, // Revalidate every 60 seconds
},
});Per-route configuration:
// src/routes/products/[id].page.tsx
export const config = {
isr: {
expiration: 3600, // 1 hour
},
};On-demand revalidation:
// src/routes/api/revalidate.post.ts
import { revalidatePath } from '@flightdev/adapter-vercel';
export async function POST(request: Request) {
const { path, secret } = await request.json();
if (secret !== process.env.REVALIDATE_SECRET) {
return Response.json({ error: 'Invalid secret' }, { status: 401 });
}
await revalidatePath(path);
return Response.json({ revalidated: true });
}Build Output
The adapter generates Vercel Build Output API format:
.vercel/
└── output/
├── config.json # Vercel configuration
├── functions/
│ ├── index.func/ # SSR function
│ └── api/
│ └── [...path].func/ # API routes
└── static/
├── assets/ # Hashed static files
└── _next/ # Client bundlesDeployment
Vercel CLI
# Install Vercel CLI
npm install -g vercel
# Build
npm run build
# Deploy to preview
vercel
# Deploy to production
vercel --prodGit Integration
Connect your repository in the Vercel dashboard for automatic deployments on push.
Environment Variables
Set in Vercel dashboard or via CLI:
vercel env add DATABASE_URL production
vercel env add API_KEY production preview developmentEnvironment Variables
| Variable | Description |
|----------|-------------|
| VERCEL | Set to 1 when running on Vercel |
| VERCEL_ENV | production, preview, or development |
| VERCEL_URL | Deployment URL |
| VERCEL_REGION | Current region code |
API Reference
Adapter Options
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| runtime | string | 'nodejs20.x' | Runtime version |
| regions | string[] | ['iad1'] | Deployment regions |
| memory | number | 1024 | Function memory (MB) |
| maxDuration | number | 30 | Max execution (seconds) |
| split | boolean | true | Split into functions |
| isr | object | - | ISR configuration |
Regions
| Code | Location |
|------|----------|
| iad1 | Washington, D.C. |
| sfo1 | San Francisco |
| cdg1 | Paris |
| hnd1 | Tokyo |
| syd1 | Sydney |
| gru1 | Sao Paulo |
License
MIT
