Automatically open browser when Next.js dev server starts.
This plugin works with webpack only.
npm install --save-dev next-plugin-open-browserAdd the plugin to your next.config.ts:
import type { NextConfig } from "next";
import { OpenBrowserPlugin } from "next-plugin-open-browser";
const nextConfig: NextConfig = {
webpack: (config, { dev, isServer }) => {
// only applies in dev mode
if (dev && !isServer) {
config.plugins.push(new OpenBrowserPlugin());
}
return config;
},
};
export default nextConfig;Start your dev server:
npm run devYour default browser will automatically open to http://localhost:3000
Screen.Recording.2025-11-29.at.10.19.50.mov
You can pass options to customize the behavior:
new OpenBrowserPlugin({
port: 3000, // custom port (default: process.env.PORT or 3000)
path: '/', // custom path (default: '/')
browser: 'chrome', // specific browser (default: system default)
background: true // open in background without focus (default: false)
})The plugin automatically handles browser names across different operating systems:
- Chrome: Works on Windows, macOS, and Linux
- Firefox: Cross-platform support
- Edge: Windows and macOS
- Brave: Cross-platform support
- Browser: Uses system default browser
Commands for maintainers:
pnpm install
pnpm build
pnpm test
pnpm playground