npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-url-checker

v1.0.3

Published

A package to check URL status and content type.

Readme

Here is an enhanced version of your README.md that includes a more structured workflow, purpose, use case, example, and general flow. This will help others understand how to use your UrlChecker package.


UrlChecker

UrlChecker is an npm package designed to check whether a URL exists and determine its content type (e.g., video, image, HTML, etc.). The package simulates a browser environment using jsdom to parse and interact with URLs. It supports asynchronous URL checks and provides an easy-to-use interface for various content types.


Purpose

The main purpose of UrlChecker is to:

  • Verify if a given URL exists and is reachable.
  • Determine the content type of the URL (video, image, HTML, etc.).
  • Display relevant media (such as videos or images) directly in a simulated browser environment.

This is particularly useful for applications needing to validate links or media URLs, and for dynamically displaying content based on the URL's type.


Use Cases

  • URL Validation: Ensure that URLs on your website are not broken.
  • Content Validation: Check the content type of a URL before displaying it.
  • Link Crawlers: Crawl URLs and categorize them by type (e.g., media, HTML).
  • Dynamic Content Display: Based on the content type, render appropriate elements (video player, iframe, image, etc.).

Installation

To install UrlChecker, run the following npm command:

npm install react-url-checker

Workflow

  1. Input: A list of URLs you want to check.
  2. Process: For each URL:
    • Send a HEAD request to check if the URL exists.
    • Retrieve the content type from the response headers.
  3. Output:
    • Status: Whether the URL exists or not.
    • Content Type: What type of content the URL points to (video, image, HTML).
    • Dynamic content rendering: Display relevant media or an iframe based on the content type.

Example

Here’s an example of how you can use UrlChecker to check multiple URLs and handle them based on their content type:

Example Usage

const { handleUrl } = require('react-url-checker');  // Import the function

// URL to check
const url = 'https://example.com/video.mp4';

// Check the URL and handle its content
handleUrl(url);

How It Works:

  1. handleUrl(url):

    • Checks if the URL exists.
    • Based on the content type (video, image, HTML, etc.), it displays the appropriate content (video player, image, iframe, etc.).
  2. Content Types:

    • Video: If the content type is a video, it will display a video player.
    • Image: If the content type is an image, it will display the image.
    • HTML: If the content type is HTML, it will display the content inside an iframe.

Functions

1. checkUrl(url)

  • Purpose: Checks if the URL exists and returns the status.
  • Parameters:
    • url (string): The URL to check.
  • Returns: An object with status (true/false) and a message.

Example:

const result = await checkUrl('https://example.com');
console.log(result);

2. handleUrl(url)

  • Purpose: Handles the URL, checks its status, and displays the content based on the type.
  • Parameters:
    • url (string): The URL to handle.
  • Returns: None (side effect of displaying the content).

Example:

handleUrl('https://example.com/video.mp4');

3. displayVideo(url, document)

  • Purpose: Displays a video element if the URL points to a video.
  • Parameters:
    • url (string): The URL of the video.
    • document (object): The document object from jsdom.
  • Returns: None.

4. displayIframe(url, document)

  • Purpose: Displays an iframe element if the URL points to an HTML page.
  • Parameters:
    • url (string): The URL of the HTML page.
    • document (object): The document object from jsdom.
  • Returns: None.

5. displayImage(url, document)

  • Purpose: Displays an image element if the URL points to an image.
  • Parameters:
    • url (string): The URL of the image.
    • document (object): The document object from jsdom.
  • Returns: None.

Example Flow

  1. Provide the URL(s):

    • You pass a URL or a list of URLs to the handleUrl function.
  2. Check the URL:

    • checkUrl(url) is called to check if the URL is reachable using a HEAD request.
  3. Determine the Content Type:

    • Based on the response headers, the function checks the Content-Type and decides how to render the URL:
      • Video: Displays a video player.
      • Image: Displays the image.
      • HTML: Embeds the page in an iframe.
  4. Output:

    • The relevant media is displayed dynamically, or a message is logged if the URL cannot be accessed.

License

This package is licensed under the MIT License. See LICENSE for more information.