Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

better-opn

ExiaSR19.3mMIT3.0.2

A better opn. Reuse the same tab on Chrome for 👨‍💻.

opn, open, opener, launch, browser

readme

better-opn

A better opn. Reuse the same tab on Chrome for 👨‍💻. Inspire by create-react-app

Install

$ yarn add better-opn

$ npm install better-opn

Usage

If you wish to overwrite the default browser, override BROWSER environment variable to your desired browser name (name is platform dependent).

const opn = require('better-opn');

opn('http://localhost:3000');

Reuse tab by match host

In case your app can navigate to another pathnames and still want to reuse opened tab, set environment variable OPEN_MATCH_HOST_ONLY=true can tell this program to find reusable tab by only match the host part of your URL.

process.env.OPEN_MATCH_HOST_ONLY = 'true';

opn('http://localhost:3000/foo/bar'); // This will reuse any tab with URL starting with http://localhost:3000/

Author

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Unreleased

[3.0.2] - 2022-01-21

Changed

  • Fallback to open is broken (#38) @erezrokah

[3.0.1] - 2021-11-04

Changed

  • Urls are opened twice (#33) @jfirebaugh

[2.1.1] - 2020-10-21

Changed

  • Handle fallback for host only matching logic (#15)

[2.1.0] - 2020-10-18

Added

  • Support reuse tab with same host (#13) @otakustay

2.0.0 - 2020-04-06

Added

Changed

  • Upgrade open from v6.4.0 to v7.0.3, see breaking change for more detail and it has been properly addressed in this commit.
  • Upgrade babel to latest release

1.0.0 - 2019-09-06

Changed

  • Drop support for Node.js version lower than 8
  • Migrate from opn to open, read this