Skip to content

michaellzc/better-opn

This branch is 1 commit ahead of master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

dce69eb · Jan 21, 2022

History

34 Commits
Apr 2, 2021
Jan 21, 2022
Apr 2, 2021
Apr 2, 2021
Sep 6, 2019
Jul 25, 2018
Apr 6, 2020
Dec 11, 2018
Jan 21, 2022
Jul 25, 2018
Jan 7, 2022
Oct 20, 2020
Jan 21, 2022
Jan 21, 2022

Repository files navigation

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