https://github.com/spa5k/is-url-online
A lightweight library for checking if a url is down or not.
https://github.com/spa5k/is-url-online
esbuild isitdown isitup library nodejs typescript
Last synced: 8 months ago
JSON representation
A lightweight library for checking if a url is down or not.
- Host: GitHub
- URL: https://github.com/spa5k/is-url-online
- Owner: spa5k
- License: mit
- Created: 2021-08-06T10:43:38.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2022-08-09T06:47:12.000Z (almost 4 years ago)
- Last Synced: 2025-04-08T20:51:19.550Z (about 1 year ago)
- Topics: esbuild, isitdown, isitup, library, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 147 MB
- Stars: 5
- Watchers: 0
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Is URL Online?
A lightweight library for checking if a url is down or not. Pretty useful while checking if the url inserted is correct one or fake one as normal url checking methods won't work.
**Supports both Server and browser due to [ohmyfetch](https://github.com/unjs/ohmyfetch)**

[](https://www.npmjs.com/package/is-url-online)
[](https://www.npmjs.com/package/is-url-online)

## Getting started
`pnpm install is-url-online`
or
`npm install is-url-online`
or
`yarn add is-url-online`
## Improvements over other libraries
- Promise based usage.
- Works on both CommonJs and EsModule based libraries.
- Smaller install size because of just one dependency.
- Built using typescript.
- Catches invalid URLs.
- Actively maintained.
- Automated Dependency update and publishing after successful tests.
- Has helper methods to deal with extra usecases.
## Usage
```ts
import { isUrlOnline } from "is-url-online";
await isUrlOnline("https://github.com/spa5k/is-url-online"); //-> true
await isUrlOnline("https://github.com/spa5k/notarepo"); //-> false
await isUrlOnline("notaurl"); //-> false
await isUrlOnline("ttps://github.com/spa5k/is-url-online abcd"); //-> false
//because of a space in middle.
```
## Utils
### Only Check URL String
This helper method will validate the URL string without checking it online.
```ts
import { isUrlString } from "is-url-online";
await isUrlString("https://google.com"); //-> true
await isUrlString("https://google.com/404ingURL"); //-> true
await isUrlString("notaurl"); //-> false
```
It uses URL module under the hood.
### Prepend HTTP/HTTPS
This helper method prepend `https://` or `http://` to humanized URLs like `github.com` and `localhost`
```ts
import { prependHttp } from "is-url-online";
// HTTPS is enabled by default.
prependHttp({ url: "github.com" }); //-> https://github.com
prependHttp({ url: "github.com", https: false }); //-> http://github.com
```
### Visualization of this Repo.

### References.
- [`url-exists`](https://github.com/boblauer/url-exists)
- [`is-url-superb`](https://github.com/sindresorhus/is-url-superb)
- [`prepend-http`](https://github.com/sindresorhus/prepend-http)