feathericons/feather · warning

feather.toSvg() is deprecated. Please use feather.icons[name

Error message

feather.toSvg() is deprecated. Please use feather.icons[name].toSvg() instead.

What it means

This is not an error but a deprecation console.warn emitted by feather.toSvg(name, attrs). The API still works, but the library directs you to the replacement: feather.icons[name].toSvg(attrs). Calling the deprecated API still validates arguments and returns the SVG string.

Source

Thrown at src/to-svg.js:11

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

  1. Replace feather.toSvg(name, attrs) with feather.icons[name].toSvg(attrs).
  2. Search your codebase for 'feather.toSvg(' and update all call sites.
  3. Suppress in tests only if migration is deferred (not recommended long-term).

Example fix

// before
const svg = feather.toSvg('circle', { class: 'icon' });

// after
const svg = feather.icons['circle'].toSvg({ class: 'icon' });
Defensive patterns

Strategy: fallback

Validate before calling

const useModernApi = typeof feather.icons === 'object';
const svg = useModernApi ? feather.icons[name].toSvg(attrs) : feather.toSvg(name, attrs);

Type guard

const hasModernIconApi = (f: typeof feather): boolean => typeof f.icons === 'object' && f.icons !== null;

Try / catch

Not strictly applicable (deprecation is a warning, not a throw). Suppress-and-verify in tests:
const spy = jest.spyOn(console, 'warn').mockImplementation();
/* call legacy API */
expect(spy).toHaveBeenCalledWith(expect.stringContaining('deprecated'));

Prevention

When it happens

Trigger: Any call to feather.toSvg('icon-name', {...}) instead of feather.icons['icon-name'].toSvg({...}).

Common situations: Old tutorials/snippets predating the icons API; legacy codebases not yet migrated; bundled old versions of application code.

Related errors


AI-assisted analysis of feathericons/feather@3dc050d974 (2026-08-30). Data as JSON: /api/errors/e95204e2e442a197. Report an issue: GitHub.