What is openurl?
The openurl npm package allows you to open URLs, files, and email addresses in the default application for your operating system. It is a simple utility that can be used to trigger the default browser, email client, or file viewer.
What are openurl's main functionalities?
Open a URL in the default web browser
This feature allows you to open a specified URL in the default web browser of the user's operating system.
const openurl = require('openurl');
openurl.open('http://www.google.com');
Open a file in the default application
This feature allows you to open a specified file in the default application associated with the file type on the user's operating system.
const openurl = require('openurl');
openurl.open('/path/to/your/file.txt');
Open an email client with a pre-filled email
This feature allows you to open the default email client with a new email draft pre-filled with the specified recipients, subject, and body.
const openurl = require('openurl');
openurl.mailto(['example@example.com'], { subject: 'Hello', body: 'Hello, world!' });
Other packages similar to openurl
open
The 'open' package provides similar functionality to 'openurl' by allowing you to open files, URLs, and email addresses in the default application. It offers more options and better cross-platform support compared to 'openurl'.
opn
The 'opn' package (now deprecated in favor of 'open') also allows you to open files and URLs in the default application. It is known for its simplicity and ease of use, similar to 'openurl'.
open-cli
The 'open-cli' package is a command-line interface for the 'open' package, allowing you to open files and URLs from the command line. It is useful for scripting and automation purposes.
openurl – Node.js module for opening URLs
openurl is a Node.js module for opening a URL via the operating system. This will usually trigger actions such as:
- http URLs: open the default browser
- mailto URLs: open the default email client
- file URLs: open a window showing the directory (on OS X)
Example interaction on the Node.js REPL:
> require("openurl").open("http://rauschma.de")
> require("openurl").open("mailto:john@example.com")
You can generate emails as follows:
require("openurl").mailto(["john@example.com", "jane@example.com"],
{ subject: "Hello!", body: "This is\nan automatically sent email!\n" });
Install via npm:
npm install openurl
I’m not yet terribly familiar with implementing npm packages, so any feedback is welcome
(especially experience reports on Windows and Linux, which I can’t test on).
Related reading: