🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

fetch-meta-tags

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-meta-tags

Fetch and parse OG tags and metadata from any URL, the fast way

1.1.0
latest
Source
npm
Version published
Weekly downloads
73
-18.89%
Maintainers
1
Weekly downloads
 
Created
Source

npm version code style: prettier

fetch-meta-tags

Fetch and parse OG tags and metadata from any URL, the fast way

Why

I wanted a way to quickly fetch OG tags from websites and get their title, description, icon and OG image. I found all existing solutions to not be ideal because:

  • They had unnecessary dependencies, increasing bundle size
  • They fetch the whole body of the website, increasing load time

fetch-meta-tags solves those problems by:

  • Having just one dependency: node-html-parser. Very lightweight library and also very fast
  • Streaming websites and stopping the HTTP request once </head> is received. No need to fetch the whole HTML of the website

Installation

$ yarn add fetch-meta-tags
$ npm install --save fetch-meta-tags

For Typescript project you can also use the types package:

$ yarn add fetch-meta-tags @types/fetch-meta-tags
$ npm install --save fetch-meta-tags @types/fetch-meta-tags

Usage

import fetchMeta from 'fetch-meta-tags'

await fetchMeta('https://luisc.xyz')

await fetchMeta('https://luisc.xyz', { method: 'GET', cache: 'no-cache' })

Outputs:

{
  url: 'https://luisc.xyz',
  title: 'Luis Cuende',
  description: 'Musings about modern philosophy, productivity and unbundling the nation state with crypto/Web3.',
  icon: 'https://luisc.xyz/favicon.ico',
  image: 'https://luisc.xyz/logo.jpg'
}

Credits

https://github.com/mozilla/page-metadata-parser for the meta tag rulesets.

License

MIT License

Keywords

fetch

FAQs

Package last updated on 08 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts