js-video-url-parser is a versatile JavaScript and TypeScript library engineered to extract detailed information from URLs across a wide array of online video platforms, including YouTube, Vimeo, Twitch, Dailymotion, Facebook, TikTok, Loom, and many others. It offers a streamlined API to parse various video URLs into a structured `videoInfo` object, encapsulating data such as the video's provider, ID, media type, and any relevant URL parameters. Furthermore, the library supports the reverse operation, allowing developers to reconstruct valid video URLs from these `videoInfo` objects with customizable formatting. The current stable version is 0.5.1. The package maintains an active release cadence, frequently adding support for new providers and addressing reported issues, indicating ongoing development and maintenance. Its primary differentiators are its extensive list of supported video services and its bidirectional functionality for both parsing and generating video URLs.
npm install js-video-url-parserVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to parse YouTube and Vimeo URLs to extract video details and how to reconstruct a YouTube URL with custom parameters.
Always validate the `videoInfo` object to contain required properties (`provider`, `id`, `mediaType`) before passing it to `urlParser.create()`. Implement checks for `undefined` return values.
Discontinue use of the library's Vimeo thumbnail parsing. Implement a custom solution for Vimeo thumbnail retrieval, potentially using the Vimeo API or other external services directly.
Remove any direct imports or references to the `template` export. It was an internal, non-functional export.
If using CommonJS, adjust your import to `const urlParser = require('js-video-url-parser').default;` to correctly access the default export. For ES Modules, use `import urlParser from 'js-video-url-parser';`.Ensure you are using `js-video-url-parser` version `0.4.2` or newer, which includes TypeScript declarations. If the problem persists, verify your `tsconfig.json` settings, especially `moduleResolution`, and ensure `node_modules/@types` is being correctly scanned, or install `@types/js-video-url-parser` if it exists (though not usually needed since types are bundled).
No dependency data recorded yet.