A Vite plugin that integrates BrowserSync into your Vite development workflow. Current stable version is v7.0.0, supporting Vite 7 and 8 with Node 20+. It provides zero-config setup for common use cases, supports BrowserSync proxy and snippet modes, and can run on dev, preview, and build --watch. Key differentiators: seamless integration with Vite's ecosystem, automatic syncing of Vite server options, and full BrowserSync features. Release cadence follows major Vite versions with breaking changes. Ships TypeScript types.
npm install vite-plugin-browser-syncVerified import paths — ran on the pinned version, not inferred.
Shows basic usage with custom BrowserSync options for the dev server, including disabling the notify banner and setting the UI port.
Upgrade to Vite 7+ and Node 20+. If unable, use version 5.0 of the plugin.
Use ESM imports; switch to dynamic import if CJS is required: const VitePluginBrowserSync = (await import('vite-plugin-browser-sync')).defaultWrap BrowserSync options inside a 'dev' object, e.g., { dev: { bs: {...} } }.Configure 'buildWatch.bs.proxy' to point to your server, e.g., proxy: 'http://localhost:3000'
Use only 'dev' mode with Astro. Alternatively, disable preview mode: { preview: { enable: false } }Convert your config to ESM (use .mjs or add 'type': 'module' in package.json) or use dynamic import: const VitePluginBrowserSync = (await import('vite-plugin-browser-sync')).defaultChange import to: import VitePluginBrowserSync from 'vite-plugin-browser-sync'
Upgrade Vite to ^7.0.0 or ^8.0.0, or downgrade the plugin to version 5.0 (supports Vite 6-7).