Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
isCssLink
✓ import { isCssLink } from 'hast-util-is-css-link'
✗ const { isCssLink } = require('hast-util-is-css-link')
This package is ESM-only since its parent ecosystem (rehype/unified) moved to ESM primarily in major versions around Node.js 16. CommonJS `require` will not work.
isCssLink (Type)
✓ import type { Node } from 'hast'
import { isCssLink } from 'hast-util-is-css-link'
The package ships with TypeScript types. The `isCssLink` function expects a HAST `Node` as input, typically imported from a `hast` type definition package or inferred by your tooling.
This quickstart demonstrates how to import and use `isCssLink` to check various HAST nodes, including valid CSS links and non-CSS elements.
import { h } from 'hastscript';
import { isCssLink } from 'hast-util-is-css-link';
const cssLinkNode = h('link', { rel: ['stylesheet', 'author'], href: 'styles.css' });
const alternateCssLinkNode = h('link', { rel: ['stylesheet'], type: 'text/css', href: 'another.css' });
const nonCssLinkNode = h('link', { rel: ['preload'], href: 'image.png' });
const scriptNode = h('script', { src: 'app.js' });
console.log('Is cssLinkNode a CSS link?', isCssLink(cssLinkNode));
console.log('Is alternateCssLinkNode a CSS link?', isCssLink(alternateCssLinkNode));
console.log('Is nonCssLinkNode a CSS link?', isCssLink(nonCssLinkNode));
console.log('Is scriptNode a CSS link?', isCssLink(scriptNode));
Debug
Known issues
breakingThe unified ecosystem, which this package is part of, updated to require Node.js 16 and changed to ESM-only exports in its major version 7.0.0 (though this package is at 3.0.1, it's tied to that ecosystem versioning).fixEnsure your project runs on Node.js 16 or newer. Migrate your imports from CommonJS `require()` to ES Modules `import` statements.
affects: <7.0.0 (of parent rehype/unified ecosystem)
breakingThe unified ecosystem now strictly uses `exports` in `package.json`, which changes module resolution. Using direct deep imports ('private APIs') is no longer supported or stable.fixOnly import directly from the package name, e.g., `import { isCssLink } from 'hast-util-is-css-link'`, and avoid internal paths like `hast-util-is-css-link/lib/foo`. If a specific utility is needed, check if it's exported directly or provided by another package. affects: >=7.0.0 (of parent rehype/unified ecosystem)
gotchaImproper handling of HTML with rehype (the parent project for HAST utilities) can lead to Cross-Site Scripting (XSS) vulnerabilities if user-controlled HTML is processed without sanitization.fixAlways use `rehype-sanitize` when processing untrusted or user-generated HTML to ensure the resulting HAST tree is safe and free from malicious content.
affects: All versions
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module .../node_modules/hast-util-is-css-link/index.js from ... not supported.
Attempting to use `require()` to import `hast-util-is-css-link`, which is an ES Module.
fixChange `const { isCssLink } = require('hast-util-is-css-link')` to `import { isCssLink } from 'hast-util-is-css-link'`. Ensure your project's `package.json` has `"type": "module"` or you are using a bundler configured for ESM. TypeError: isCssLink is not a function (or similar undefined export error)
Incorrectly importing a named export as a default export, or attempting to import a non-existent export.
fixEnsure you are using named imports: `import { isCssLink } from 'hast-util-is-css-link'`. There is no default export for this package. Audit
Dependencies
No dependency data recorded yet.