{"id":15288628,"url":"https://github.com/qodesmith/vite-plugin-vercel-api","last_synced_at":"2026-04-29T08:05:39.107Z","repository":{"id":61590762,"uuid":"547282332","full_name":"qodesmith/vite-plugin-vercel-api","owner":"qodesmith","description":null,"archived":false,"fork":false,"pushed_at":"2023-09-24T18:32:40.000Z","size":838,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-01T04:11:51.930Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qodesmith.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-07T12:31:57.000Z","updated_at":"2022-10-07T12:32:10.000Z","dependencies_parsed_at":"2024-12-01T12:52:39.341Z","dependency_job_id":null,"html_url":"https://github.com/qodesmith/vite-plugin-vercel-api","commit_stats":{"total_commits":22,"total_committers":1,"mean_commits":22.0,"dds":0.0,"last_synced_commit":"b65e1bbe65e462bee847e7ef03c86a1118697d28"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qodesmith%2Fvite-plugin-vercel-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qodesmith%2Fvite-plugin-vercel-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qodesmith%2Fvite-plugin-vercel-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qodesmith%2Fvite-plugin-vercel-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qodesmith","download_url":"https://codeload.github.com/qodesmith/vite-plugin-vercel-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245217791,"owners_count":20579297,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-30T15:51:25.423Z","updated_at":"2026-04-29T08:05:34.074Z","avatar_url":"https://github.com/qodesmith.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vite-plugin-vercel-api\n\nMimics Vercel's `/api` functionality locally. No need to be online or run `vercel dev`. You can simply run `npm run dev` to start Vite locally and use the `/api` directory the same way Vercel parses it in production.\n\nThis plugin provides 2 main features:\n\n1.  Traverses the `/api` directory at the root of your project and parses files\n    the same way Vercel does in production.\n2.  Adds a number of middleware features found on the request and response\n    objects in Vercel's serverless functions.\n\nSee https://nextjs.org/docs/api-routes/dynamic-api-routes for how the logic works for the `/api` directory, its files, and its folder structure.\n\nPlease note that Vercel `/api` features do NOT have parity with Next.js `/pages/api`. In particular, Vercel does not support `[...catchAll]` or `[[...optionaCatchAll]]` routes - see https://github.com/vercel/community/discussions/947.\n\nSee https://vercel.com/docs/runtimes#official-runtimes/node-js/node-js-request-and-response-objects for what middleware Vercel exposes on the request and response objects in serverless functions.\n\n## Installation\n\n`npm i -D vite-plugin-vercel-api`\n\n## Usage\n\n```javascript\nimport {defineConfig} from 'vite'\nimport vitePluginVercelApi from 'vite-plugin-vercel-api'\n\nexport default defineConfig({\n  plugins: [vitePluginVercelApi()],\n})\n```\n\nOr with `require` syntax:\n\n```javascript\nconst {defineConfig} = require('vite')\nconst vitePluginVercelApi = require('vite-plugin-vercel-api')\n\nmodule.exports = defineConfig({\n  plugins: [vitePluginVercelApi()],\n})\n```\n\n## Options\n\n### `apiDir`\n\nVercel looks for files in the `api` directory. This plugin will also default to looking for an `api` folder. If you want to direct this plugin to process a differnt folder, this is the option for you.\n\n### `debugOptions`\n\nThis option will log values and errors of the build process to the console. This is a good way to debug what's happening under the hood. Using this option will override the config with `clearScreen: true`.\n\n- `true` - shorthand for including all logging options.\n- `'apiFiles'` - log the files used for api endpoints.\n- `'apiPath'` - log the path used for the api.\n- `'apiRoutes'` - log the routes constructed for Express.\n- `'buildResults'` - log the esbuild results. Uses console.log which does _not_ log deeply nested object values.\n- `'buildResultsDeep'` - log the esbuild results. Uses console.dir which _does_ log deeply nested object values. _NOTE: this can lead to large logs in the console!_\n- `'failedRouteImports'` - log errors encountered with dynamically importing the route handler files.\n\nExample usage:\n\n```javascript\nimport {defineConfig} from 'vite'\nimport vitePluginVercelApi from 'vite-plugin-vercel-api'\n\nexport default defineConfig({\n  plugins: [\n    vitePluginVercelApi({\n      apiDir: 'myApi',\n      debugOptions: ['apiFiles', 'buildResultsDeep', 'failedRouteImports'],\n    }),\n  ],\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqodesmith%2Fvite-plugin-vercel-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqodesmith%2Fvite-plugin-vercel-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqodesmith%2Fvite-plugin-vercel-api/lists"}