A Vite plugin (v0.4.0) that automatically starts a local Convex backend during development, deploys functions on startup, watches for changes in the convex/ directory, and injects VITE_CONVEX_URL and VITE_CONVEX_SITE_URL environment variables. It persists backend state across restarts based on git branch, supports custom logging, and provides methods like getAdminKey(). The plugin detects the package manager (npm, yarn, pnpm, bun) automatically. Requires Vite ^7.0.0.
npm install convex-vite-pluginVerified import paths — ran on the pinned version, not inferred.
Shows minimum plugin setup with convexLocal() and usage of injected VITE_CONVEX_URL.
Update envVars callback to use object destructuring: envVars: ({ vitePort, resolvedUrls }) => ({ ... })Use import syntax or configure tsconfig with 'module': 'ESNext' and 'moduleResolution': 'bundler'.
Use the 'reset' option to clear state when switching branches, or manually delete the .convex directory.
No action needed; older versions that bundled bunx require upgrading. If using bun, ensure npm_config_user_agent is set.
Upgrade Vite to version 7 or later.
bun add convex-vite-plugin or npm install convex-vite-plugin
Use import { convexLocal } from 'convex-vite-plugin'Ensure envVars returns a record of string keys starting with 'VITE_', e.g., { VITE_MY_VAR: 'value' }