fetch-meta-tags v1.1.0 is a lightweight JavaScript library for fetching and parsing Open Graph tags, title, description, icon, and image from any URL. It uses node-html-parser to efficiently stream the HTML and stops the HTTP request once </head> is received, minimizing bandwidth and load time compared to libraries that fetch the entire page. The library has a small bundle size with minimal dependencies. It is published on npm and supports both CommonJS and ES modules. The release cadence is low; it has seen only a few versions. Key differentiators include its performance-oriented streaming approach and minimal dependency footprint. It is suitable for server-side or edge environments (Node.js, Deno, Bun) that support fetch and streaming. The package includes TypeScript definitions via @types/fetch-meta-tags.
npm install fetch-meta-tagsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates importing and using the default export to fetch Open Graph metadata from a URL with both default and custom fetch options.
Ensure all relevant OG tags are within <head>. The library intentionally stops parsing after </head>.
Use Node.js 18+ or add a fetch polyfill (e.g., node-fetch) and assign to globalThis.fetch.
Verify the returned object contains only the predefined keys: url, title, description, icon, image. For additional metadata, parse manually.
Pass redirect: 'follow' in the options object if needed: await fetchMeta(url, { redirect: 'follow' })This is a known limitation. Use with well-formed HTML pages. The library adds a timeout fallback (default 10 seconds).
Change to: import fetchMeta from 'fetch-meta-tags';
Run: npm install --save-dev @types/fetch-meta-tags ; or ensure tsconfig.json includes "moduleResolution": "node"
Upgrade to Node.js 18+ or install a fetch polyfill like 'node-fetch' and assign it to globalThis.fetch.
Increase the timeout by passing a custom signal via AbortController in the options: fetchMeta(url, { signal: AbortSignal.timeout(20000) })