{"record":{"id":"e95204e2e442a197","repo":"feathericons/feather","slug":"feather-tosvg-is-deprecated-please-use-feather","errorCode":null,"errorMessage":"feather.toSvg() is deprecated. Please use feather.icons[name].toSvg() instead.","messagePattern":"feather\\.toSvg\\(\\) is deprecated\\. Please use feather\\.icons\\[name\\]\\.toSvg\\(\\) instead\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/to-svg.js","lineNumber":11,"sourceCode":"import icons from './icons';\n\n/**\n * Create an SVG string.\n * @deprecated\n * @param {string} name\n * @param {Object} attrs\n * @returns {string}\n */\nfunction toSvg(name, attrs = {}) {\n  console.warn(\n    'feather.toSvg() is deprecated. Please use feather.icons[name].toSvg() instead.',\n  );\n\n  if (!name) {\n    throw new Error('The required `key` (icon name) parameter is missing.');\n  }\n\n  if (!icons[name]) {\n    throw new Error(\n      `No icon matching '${name}'. See the complete list of icons at https://feathericons.com`,\n    );\n  }\n\n  return icons[name].toSvg(attrs);\n}\n\nexport default toSvg;\n","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/feathericons/feather/blob/3dc050d97405062eba78aa57115c0a15c63abdaa/src/to-svg.js#L1-L29","documentation":"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.","triggerScenarios":"Any call to feather.toSvg('icon-name', {...}) instead of feather.icons['icon-name'].toSvg({...}).","commonSituations":"Old tutorials/snippets predating the icons API; legacy codebases not yet migrated; bundled old versions of application code.","solutions":["Replace feather.toSvg(name, attrs) with feather.icons[name].toSvg(attrs).","Search your codebase for 'feather.toSvg(' and update all call sites.","Suppress in tests only if migration is deferred (not recommended long-term)."],"exampleFix":"// before\nconst svg = feather.toSvg('circle', { class: 'icon' });\n\n// after\nconst svg = feather.icons['circle'].toSvg({ class: 'icon' });","handlingStrategy":"fallback","validationCode":"const useModernApi = typeof feather.icons === 'object';\nconst svg = useModernApi ? feather.icons[name].toSvg(attrs) : feather.toSvg(name, attrs);","typeGuard":"const hasModernIconApi = (f: typeof feather): boolean => typeof f.icons === 'object' && f.icons !== null;","tryCatchPattern":"Not strictly applicable (deprecation is a warning, not a throw). Suppress-and-verify in tests:\nconst spy = jest.spyOn(console, 'warn').mockImplementation();\n/* call legacy API */\nexpect(spy).toHaveBeenCalledWith(expect.stringContaining('deprecated'));","preventionTips":["Never call feather.toSvg() directly; use feather.icons[name].toSvg()","Keep dependencies updated so deprecations surface in CI","Search codebases for 'feather.toSvg(' when upgrading","Wrap icon rendering in one utility module so API changes are localized"],"tags":["deprecated-api","console-warning","migration"],"backgroundTag":"deprecated-api-usage","analyzedSha":"3dc050d97405062eba78aa57115c0a15c63abdaa","analyzedAt":"2026-08-30T12:01:49.665Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}