feathericons/feather · error · Error
The required `key` (icon name) parameter is missing.
Error message
The required `key` (icon name) parameter is missing.
What it means
feather.toSvg(name, attrs) (deprecated) requires an icon name string as its first argument; it is used to look up the icon in the internal icons map. When the argument is undefined, null, or an empty string, the library cannot proceed and throws. The method is deprecated in favor of feather.icons[name].toSvg().
Source
Thrown at src/to-svg.js:16
import icons from './icons';
/**
* Create an SVG string.
* @deprecated
* @param {string} name
* @param {Object} attrs
* @returns {string}
*/
function toSvg(name, attrs = {}) {
console.warn(
'feather.toSvg() is deprecated. Please use feather.icons[name].toSvg() instead.',
);
if (!name) {
throw new Error('The required `key` (icon name) parameter is missing.');
}
if (!icons[name]) {
throw new Error(
`No icon matching '${name}'. See the complete list of icons at https://feathericons.com`,
);
}
return icons[name].toSvg(attrs);
}
export default toSvg;
View on GitHub (pinned to 3dc050d974)
Solutions
- Pass a non-empty icon name string: feather.toSvg('circle').
- Better, migrate to the non-deprecated API: feather.icons[name].toSvg(attrs).
- Add a default value for the variable/prop that supplies the name.
- Validate typeof name === 'string' && name before calling.
Example fix
// before feather.toSvg(iconName); // iconName is undefined // after feather.icons['circle'].toSvg();
Defensive patterns
Strategy: validation
Validate before calling
if (typeof name !== 'string' || name.length === 0) throw new Error('icon name is required'); Type guard
const hasIconName = (v: unknown): v is string => typeof v === 'string' && v.trim().length > 0;
Try / catch
try {
const svg = feather.icons[name].toSvg(attrs);
} catch (e) {
if (e.message.includes('required `key`')) {
// fall back to a default icon or surface a config error
} else {
throw e;
}
} Prevention
- Provide default values for props/vars that supply icon names
- Migrate from feather.toSvg() to feather.icons[name].toSvg()
- Validate icon name inputs at configuration boundaries
When it happens
Trigger: Calling feather.toSvg() with no arguments, or with a variable that is undefined/null/'' at call time (e.g. a failed config lookup or a missing prop).
Common situations: Passing a dynamically computed icon name that ends up empty; a component prop with no default; migration code calling the old API with an unset variable.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
AI-assisted analysis of feathericons/feather@3dc050d974 (2026-08-30).
Data as JSON: /api/errors/6691b2c1c58fb566.
Report an issue: GitHub.