vite-plugin-vercel
raw JSON → 11.0.3 verified Mon Apr 27 auth: no javascript
Vite adapter for Vercel that bundles applications according to the Vercel Output API. Version 11.0.3 requires Vite >=7.1. Supports SSG/static files, SSR/serverless functions with auto-bundling from the api folder, ISR/prerender functions, Edge functions and Edge middleware. Differentiates from @vercel/build by not forcing api folder builds, offering flexible endpoint mapping via getVercelEntries and per-endpoint configuration (edge, headers, streaming, isr). Actively maintained with frequent releases.
Common errors
error Error: require() of ES Module not supported: vite-plugin-vercel ↓
cause Using CommonJS require to import an ESM-only package.
fix
Switch to ESM by using import statements or set "type": "module" in package.json.
error Module not found: Can't resolve 'vite-plugin-vercel' ↓
cause Package not installed or missing from node_modules.
fix
Run npm install -D vite-plugin-vercel (or equivalent with yarn/pnpm/bun).
error TypeError: vercel is not a function ↓
cause Importing the default export incorrectly (e.g., using named import for default).
fix
Use
import vercel from 'vite-plugin-vercel' (default import). error Serverless Function timed out (maxDuration exceeded) ↓
cause Function execution exceeded the defaultMaxDuration set in config or Vercel plan limit.
fix
Increase defaultMaxDuration in plugin options or optimize function code.
error Error: getVercelEntries is not defined ↓
cause Using CJS require or incorrect named import.
fix
Use
import { getVercelEntries } from 'vite-plugin-vercel' in an ESM context. Warnings
breaking Version 11 dropped support for Vite 6 and earlier. Only Vite >=7.1 is supported. ↓
fix Upgrade Vite to >=7.1 or stay on v10.x
breaking Default export renamed in v7 from createVercel to vercel plugin function. ↓
fix Use `import vercel from 'vite-plugin-vercel'` instead of `import createVercel`
gotcha If you place files inside the /api folder, @vercel/build will force-bundle them. Use a different folder like endpoints/api and map with getVercelEntries. ↓
fix Move API files to a custom folder (e.g., endpoints/api) and configure entries accordingly.
deprecated The `additionalEndpoints` config option is deprecated in favor of `getVercelEntries` since v10. ↓
fix Use getVercelEntries to define endpoints programmatically.
gotcha Edge functions using `export const edge = true` must return a Response object; streaming responses require `export const streaming = true`. ↓
fix Ensure edge function handlers return Response and set streaming flag if needed.
Install
npm install vite-plugin-vercel yarn add vite-plugin-vercel pnpm add vite-plugin-vercel Imports
- default (vercel) wrong
const vercel = require('vite-plugin-vercel')correctimport vercel from 'vite-plugin-vercel' - getVercelEntries wrong
const { getVercelEntries } = require('vite-plugin-vercel')correctimport { getVercelEntries } from 'vite-plugin-vercel' - type VercelOptions wrong
import { VercelOptions } from 'vite-plugin-vercel' (runtime import)correctimport type { VercelOptions } from 'vite-plugin-vercel'
Quickstart
// vite.config.ts
import { defineConfig } from 'vite';
import vercel from 'vite-plugin-vercel';
import { getVercelEntries } from 'vite-plugin-vercel';
const entries = await getVercelEntries('endpoints/api', { destination: 'api' });
export default defineConfig({
plugins: [vercel({ entries })]
});
// endpoints/api/hello.ts
export default async function handler(request: Request): Promise<Response> {
return new Response('Hello, Vercel!', { status: 200 });
}