This library provides a typed solution for parsing HTTP referer URLs, classifying them into categories such as search engines, social media, email providers, paid advertising platforms, and notably, AI chatbots. It is currently stable at version 1.1.0, with minor releases occurring periodically to introduce new features, expand database coverage, and address maintenance. A key differentiator is its comprehensive referer database, which is compiled from both Snowplow's referer-parser and Matomo's searchengine-and-social-list, covering over 450 sources. Recent updates significantly expanded its AI/chatbot detection capabilities to include popular models like ChatGPT, Claude, and Google Gemini, alongside broader social media coverage for platforms like X (formerly Twitter) and Bluesky. The library offers full TypeScript support, ensuring type inference, and is designed to work in both client-side (browser) and server-side (Node.js) JavaScript environments.
npm install ts-referer-parserVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to parse various types of referer URLs, including direct traffic, social media, search engines, and AI chatbots, showing how to obtain the referer string in both browser and Node.js environments.
Remove the `await` keyword from all calls to `parse()`. For example, change `const result = await parse(...)` to `const result = parse(...)`.
Upgrade to `ts-referer-parser@1.0.9` or later. If issues persist after upgrading, clear `node_modules` and your package manager's cache, then reinstall dependencies.
Update to `ts-referer-parser@1.0.8` or newer to ensure all bundled dependencies and the build process are patched against known vulnerabilities.
Update your `package.json` dependency to `ts-referer-parser` and adjust all import paths accordingly to `from 'ts-referer-parser'`.
Remove the `await` keyword from the `parse()` call. The function now returns the `Referer` object directly. Example: `const result = parse(referer, url);`
Ensure you are using `ts-referer-parser@1.0.9` or a newer version. If the problem persists, delete your `node_modules` directory and `package-lock.json` (or `yarn.lock`, `pnpm-lock.yaml`) and reinstall dependencies.
No dependency data recorded yet.