Skip to content

Commit caa3487

Browse files
committed
chore(README): create
1 parent 0907391 commit caa3487

File tree

5 files changed

+218
-8
lines changed

5 files changed

+218
-8
lines changed

README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# next-plugin-open-browser
2+
3+
Automatically open browser when Next.js dev server starts.
4+
5+
This plugin works with **webpack only**.
6+
7+
## Installation
8+
9+
```bash
10+
npm install --save-dev next-plugin-open-browser
11+
```
12+
13+
## Usage
14+
15+
Add the plugin to your `next.config.ts`:
16+
17+
```typescript
18+
import type { NextConfig } from "next";
19+
import { OpenBrowserPlugin } from "next-plugin-open-browser";
20+
21+
const nextConfig: NextConfig = {
22+
webpack: (config, { dev, isServer }) => {
23+
// only applies in dev mode
24+
if (dev && !isServer) {
25+
config.plugins.push(new OpenBrowserPlugin());
26+
}
27+
return config;
28+
},
29+
};
30+
31+
export default nextConfig;
32+
```
33+
34+
Start your dev server:
35+
36+
```bash
37+
npm run dev
38+
```
39+
40+
Your default browser will automatically open to `http://localhost:3000`
41+
42+
https://github.com/user-attachments/assets/44f57d2d-4427-4751-9ed2-7a06541e8ce3
43+
44+
## Configuration
45+
46+
You can pass options to customize the behavior:
47+
48+
```typescript
49+
new OpenBrowserPlugin({
50+
port: 3000, // custom port (default: process.env.PORT or 3000)
51+
path: '/', // custom path (default: '/')
52+
browser: 'chrome', // specific browser (default: system default)
53+
background: true // open in background without focus (default: false)
54+
})
55+
```
56+
57+
## Supported Browsers
58+
59+
The plugin automatically handles browser names across different operating systems:
60+
61+
- **Chrome**: Works on Windows, macOS, and Linux
62+
- **Firefox**: Cross-platform support
63+
- **Edge**: Windows and macOS
64+
- **Brave**: Cross-platform support
65+
- **Browser**: Uses system default browser
66+
67+
## Development
68+
69+
Commands for maintainers:
70+
71+
```bash
72+
pnpm install
73+
pnpm build
74+
pnpm test
75+
pnpm playground
76+
```
77+
78+
## License
79+
80+
[MIT](./LICENSE)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Changelog
2+
3+
## [0.1.1] - 2025-11-30
4+
5+
First stable release
6+
7+
### Added
8+
- Initial release
9+
- Automatic browser opening when Next.js dev server starts
10+
- Support for custom port configuration
11+
- Support for custom path configuration
12+
- Browser selection support (Chrome, Firefox, Edge, Brave)
13+
- Background mode option to open browser without stealing focus
14+
- OS-specific browser name normalization (Chrome handling for macOS/Linux/Windows)
15+
- Comprehensive test suite with 17 tests
16+
- Full JSDoc documentation
17+
- TypeScript type definitions
18+
19+
### Features
20+
- Only opens browser once (not on every hot-reload)
21+
- Works with webpack-based Next.js projects only
22+
- Supports Next.js >= 13.0.0
23+
- ESM-based implementation using modern `open` package v11
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 simoncdn
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# next-plugin-open-browser
2+
3+
Automatically open browser when Next.js dev server starts.
4+
5+
This plugin works with **webpack only**.
6+
7+
## Installation
8+
9+
```bash
10+
npm install --save-dev next-plugin-open-browser
11+
```
12+
13+
## Usage
14+
15+
Add the plugin to your `next.config.ts`:
16+
17+
```typescript
18+
import type { NextConfig } from "next";
19+
import { OpenBrowserPlugin } from "next-plugin-open-browser";
20+
21+
const nextConfig: NextConfig = {
22+
webpack: (config, { dev, isServer }) => {
23+
// only applies in dev mode
24+
if (dev && !isServer) {
25+
config.plugins.push(new OpenBrowserPlugin());
26+
}
27+
return config;
28+
},
29+
};
30+
31+
export default nextConfig;
32+
```
33+
34+
Start your dev server:
35+
36+
```bash
37+
npm run dev
38+
```
39+
40+
Your default browser will automatically open to `http://localhost:3000`
41+
42+
https://github.com/user-attachments/assets/44f57d2d-4427-4751-9ed2-7a06541e8ce3
43+
44+
## Configuration
45+
46+
You can pass options to customize the behavior:
47+
48+
```typescript
49+
new OpenBrowserPlugin({
50+
port: 3000, // custom port (default: process.env.PORT or 3000)
51+
path: '/', // custom path (default: '/')
52+
browser: 'chrome', // specific browser (default: system default)
53+
background: true // open in background without focus (default: false)
54+
})
55+
```
56+
57+
## Supported Browsers
58+
59+
The plugin automatically handles browser names across different operating systems:
60+
61+
- **Chrome**: Works on Windows, macOS, and Linux
62+
- **Firefox**: Cross-platform support
63+
- **Edge**: Windows and macOS
64+
- **Brave**: Cross-platform support
65+
- **Browser**: Uses system default browser
66+
67+
## Development
68+
69+
Commands for maintainers:
70+
71+
```bash
72+
pnpm install
73+
pnpm build
74+
pnpm test
75+
pnpm playground
76+
```
77+
78+
## License
79+
80+
[MIT](./LICENSE)

packages/next-plugin-open-browser/package.json

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
{
22
"name": "next-plugin-open-browser",
3-
"description": "Show QR code on Next.js dev server start",
3+
"description": "Automatically open browser when Next.js dev server starts",
44
"version": "0.1.1",
55
"license": "MIT",
66
"author": "simoncdn",
77
"type": "module",
88
"main": "dist/index.js",
99
"types": "dist/index.d.ts",
1010
"files": [
11-
"dist"
11+
"dist",
12+
"README.md",
13+
"LICENSE",
14+
"CHANGELOG.md"
1215
],
1316
"scripts": {
1417
"build": "tsc",
1518
"dev": "tsc --watch",
1619
"test": "vitest",
1720
"test:ui": "vitest --ui",
18-
"test:run": "vitest run"
21+
"test:run": "vitest run",
22+
"prepublishOnly": "pnpm test:run && pnpm build"
1923
},
2024
"repository": {
2125
"type": "git",
@@ -39,13 +43,15 @@
3943
"keywords": [
4044
"next",
4145
"nextjs",
42-
"qrcode",
4346
"plugin",
44-
"open browser",
45-
"server start",
4647
"webpack",
47-
"mobile",
48-
"dev"
48+
"browser",
49+
"open",
50+
"auto-open",
51+
"development",
52+
"dev-server",
53+
"chrome",
54+
"firefox"
4955
],
5056
"dependencies": {
5157
"open": "^11.0.0"

0 commit comments

Comments
 (0)