# @xbaijun/open-browser

> Automatically open browser when starting development server

Latest version **1.0.6** (published 2022-11-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @xbaijun/open-browser
pnpm add @xbaijun/open-browser
yarn add @xbaijun/open-browser
bun add @xbaijun/open-browser
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2022-11-28 |
| First published | 2022-11-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 20.7 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | yes |
| GitHub stars | 2 |
| Author | xiaobaijun |
| Maintainers | xiaobaijun |
| Keywords | open, browser, open-browser, auto-open |

## Links

- npm: https://www.npmjs.com/package/@xbaijun/open-browser
- Repository: https://github.com/YuanBingrui/open-browser
- Issues: https://github.com/YuanBingrui/open-browser/issues
- npm.io page: https://npm.io/package/@xbaijun/open-browser

## Dependencies (4)

- [ip](https://npm.io/package/ip.md) ^1.1.8
- [open](https://npm.io/package/open.md) ^8.4.0
- [picocolors](https://npm.io/package/picocolors.md) ^1.0.0
- [cross-spawn](https://npm.io/package/cross-spawn.md) ^7.0.3

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.6 (latest) — 2022-11-28
- 1.0.5 — 2022-11-28
- 1.0.4 — 2022-11-27
- 1.0.3 — 2022-11-27
- 1.0.2 — 2022-11-27
- 1.0.1 — 2022-11-27
- 1.0.0 — 2022-11-25

## README

# open-browser

Automatically open browser when starting development server

## features

1. automatically open browser default localhost
2. automatically open browser by local ip
3. support url with path or query

## Install

```
// npm
npm install @xbaijun/open-browser -D
// yarn
yarn add @xbaijun/open-browser -D
// pnpm
pnpm add @xbaijun/open-browser -D
```

## How to use it

```
const openBrowser = require('./cjs/index');
const http = require('node:http');

const OB = new openBrowser({
  ip: true,
  port: 3000,
});

http
  .createServer((req, res) => {
    res.write('hello world\n');
    res.end();
  })
  .listen(3000, () => {
    OB.open();
  });
```

## Docs

```
export interface OpenBrowserOptions {
  ip?: boolean;
  port?: number;
  url?: string;
  browser?: string;
  path?: string;
}

declare class OpenBrowser {
  private url: string;
  private browser: string;
  constructor(options: OpenBrowserOptions);
  getLocalIP(): string;
  open(browser?: string, url?: string): void;
}
```

---
_Source: https://npm.io/package/@xbaijun/open-browser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
