{"id":22908,"library":"vite-plugin-vercel","title":"vite-plugin-vercel","description":"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.","status":"active","version":"11.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/magne4000/vite-plugin-vercel","tags":["javascript"],"install":[{"cmd":"npm install vite-plugin-vercel","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-vercel","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-vercel","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency, required as the build tool; version >=7.1","package":"vite","optional":false}],"imports":[{"note":"ESM-only; cannot use require in CJS. Since v11, no default export is named, but the default export is the plugin function.","wrong":"const vercel = require('vite-plugin-vercel')","symbol":"default (vercel)","correct":"import vercel from 'vite-plugin-vercel'"},{"note":"Named export, not available in CJS. Used to generate endpoint entries with auto-mapping.","wrong":"const { getVercelEntries } = require('vite-plugin-vercel')","symbol":"getVercelEntries","correct":"import { getVercelEntries } from 'vite-plugin-vercel'"},{"note":"TypeScript type only; import type to avoid bundling issue.","wrong":"import { VercelOptions } from 'vite-plugin-vercel' (runtime import)","symbol":"type VercelOptions","correct":"import type { VercelOptions } from 'vite-plugin-vercel'"}],"quickstart":{"code":"// vite.config.ts\nimport { defineConfig } from 'vite';\nimport vercel from 'vite-plugin-vercel';\nimport { getVercelEntries } from 'vite-plugin-vercel';\n\nconst entries = await getVercelEntries('endpoints/api', { destination: 'api' });\n\nexport default defineConfig({\n  plugins: [vercel({ entries })]\n});\n\n// endpoints/api/hello.ts\nexport default async function handler(request: Request): Promise<Response> {\n  return new Response('Hello, Vercel!', { status: 200 });\n}","lang":"typescript","description":"Minimal Vite config with Vercel plugin, endpoint mapping via getVercelEntries, and a sample API route."},"warnings":[{"fix":"Upgrade Vite to >=7.1 or stay on v10.x","message":"Version 11 dropped support for Vite 6 and earlier. Only Vite >=7.1 is supported.","severity":"breaking","affected_versions":">=11.0.0"},{"fix":"Use `import vercel from 'vite-plugin-vercel'` instead of `import createVercel`","message":"Default export renamed in v7 from createVercel to vercel plugin function.","severity":"breaking","affected_versions":">=7.0.0 <11"},{"fix":"Move API files to a custom folder (e.g., endpoints/api) and configure entries accordingly.","message":"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.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use getVercelEntries to define endpoints programmatically.","message":"The `additionalEndpoints` config option is deprecated in favor of `getVercelEntries` since v10.","severity":"deprecated","affected_versions":">=10.0.0"},{"fix":"Ensure edge function handlers return Response and set streaming flag if needed.","message":"Edge functions using `export const edge = true` must return a Response object; streaming responses require `export const streaming = true`.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Switch to ESM by using import statements or set \"type\": \"module\" in package.json.","cause":"Using CommonJS require to import an ESM-only package.","error":"Error: require() of ES Module not supported: vite-plugin-vercel"},{"fix":"Run npm install -D vite-plugin-vercel (or equivalent with yarn/pnpm/bun).","cause":"Package not installed or missing from node_modules.","error":"Module not found: Can't resolve 'vite-plugin-vercel'"},{"fix":"Use `import vercel from 'vite-plugin-vercel'` (default import).","cause":"Importing the default export incorrectly (e.g., using named import for default).","error":"TypeError: vercel is not a function"},{"fix":"Increase defaultMaxDuration in plugin options or optimize function code.","cause":"Function execution exceeded the defaultMaxDuration set in config or Vercel plan limit.","error":"Serverless Function timed out (maxDuration exceeded)"},{"fix":"Use `import { getVercelEntries } from 'vite-plugin-vercel'` in an ESM context.","cause":"Using CJS require or incorrect named import.","error":"Error: getVercelEntries is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}