Troubleshooting
Common issues and solutions for the icondev NPM package
Configuration Issues
"Configuration not found" Error
Symptom: Error when importing icons
Error: icondev.json not found. Run `npx icondev init` to set up the project.Solution:
npx icondev initThis creates icondev.json with your project configuration and downloads all available icons metadata.
Missing icondev.json File
Symptom: Icons fail to load in Node.js/SSR
Error: Cannot find icondev.json in project rootSolution:
- Make sure you ran
npx icondev init - Check that
icondev.jsonexists in your project root - Verify the file is not in
.gitignoreif working with a fresh clone
# Check if file exists
ls -la icondev.json
# If missing, run init
npx icondev init
# If exists but outdated, sync
npx icondev syncInvalid API Key
Symptom: Init command fails or icons don't load
Error: Invalid API key or unable to fetch project detailsCauses:
- Wrong API key format
- API key doesn't have access to project
- Network issues
Solution:
- Check your API key starts with
pk_ - Verify API key has access to your project in dashboard
- Re-run init:
npx icondev initIcons Not Rendering
Check Package Installation
npm list icondevIf not installed:
npm install icondevIcons Don't Appear
Symptom: No error, but icons don't render
Debugging steps:
-
Check console for errors: Open browser DevTools → Console tab
-
Verify icon name:
import { getAvailableIcons } from 'icondev' console.log(getAvailableIcons()) -
Check icondev.json:
cat icondev.jsonMake sure it contains your icons array
-
Try preloading:
import { preloadIcons } from 'icondev' await preloadIcons(['home'])
"Icon not found" Error
Symptom: Specific icon fails to load
Error: Icon "my-icon" not foundSolutions:
-
Check icon exists in your project: Visit your Icon.dev dashboard and verify the icon exists
-
Refresh icondev.json:
npx icondev syncOr use
npx icondev initto re-initialize from scratch -
Check icon slug: Icon names are case-sensitive. Use exact slug from dashboard.
Browser Issues
Icons Work in SSR but Not in Browser
Symptom: Icons render during SSR but fail in browser
Cause: Missing IconDevProvider in client-only setup
Solution:
For client-only apps (no SSR), wrap your app with IconDevProvider:
import { IconDevProvider } from 'icondev/react'
const config = {
apiKey: 'pk_...',
projectSlug: 'my-project',
cdnUrl: 'https://cdn.icon.dev'
}
function App() {
return (
<IconDevProvider config={config}>
<YourApp />
</IconDevProvider>
)
}IconDevProvider is only needed for pure client-side apps. SSR frameworks (Next.js, Nuxt, Remix) work automatically.
CORS Errors
Symptom: CORS error when loading icons
Access to fetch at 'https://cdn.icon.dev/...' has been blocked by CORS policyThis should NOT happen! Icons are served from public CDN with CORS enabled.
If you see this error:
- Check if you're behind a proxy/VPN
- Try disabling browser extensions
- Contact support at support@icon.dev
Framework-Specific Issues
Next.js: "Module not found" Error
Symptom:
Module not found: Can't resolve 'icondev/react'Solution:
-
Reinstall package:
rm -rf node_modules package-lock.json npm install -
Restart Next.js dev server:
npm run dev
Next.js: Hydration Mismatch
Symptom:
Warning: Text content did not match. Server: "" Client: "<svg>..."Cause: Icon loads differently on server vs client
Solution:
Use skeleton loading state:
'use client'
import { useState, useEffect } from 'react'
import { Icon } from 'icondev/react'
export function SafeIcon({ name, ...props }) {
const [mounted, setMounted] = useState(false)
useEffect(() => setMounted(true), [])
if (!mounted) {
return <div className="skeleton w-6 h-6" />
}
return <Icon name={name} {...props} />
}Vue: Icon Not Reactive
Symptom: Changing icon name prop doesn't update the icon
Solution:
The useIcon composable should automatically react to prop changes. If not:
<script setup>
import { watch } from 'vue'
import { Icon, useIcon } from 'icondev/vue'
const props = defineProps<{ name: string }>()
// Force reload on name change
watch(() => props.name, () => {
// Icon component handles this automatically
})
</script>
<template>
<Icon :name="name" />
</template>Performance Issues
Icons Load Slowly
Symptoms:
- Long wait times for icons to appear
- Many network requests
Solutions:
-
Preload critical icons:
import { preloadIcons } from 'icondev' // On app mount preloadIcons(['logo', 'menu', 'close', 'home']) -
Check CDN latency: Open DevTools → Network tab → Look for
cdn.icon.devrequests- Should be < 50ms with CDN caching
- If slow, might be cold cache (first request)
-
Use loading states:
import { useIcon } from 'icondev/react' function MyIcon({ name }) { const { svg, loading } = useIcon(name) if (loading) return <Skeleton /> return <div dangerouslySetInnerHTML={{ __html: svg }} /> }
Memory Usage Too High
Symptom: App uses too much memory
Cause: Too many icons cached in memory
Solution:
Clear cache periodically:
import { clearCache } from 'icondev'
// Clear cache when navigating away from icon-heavy page
clearCache()Only clear cache if you have 1000+ icons loaded. Normal usage shouldn't require this.
TypeScript Issues
Type Errors for Icon Names
Symptom:
Type 'string' is not assignable to type 'IconName'This is a future feature! Currently, icon names are typed as string.
Workaround:
const iconName: string = 'home'
<Icon name={iconName} />Missing Type Definitions
Symptom:
Could not find a declaration file for module 'icondev'Solution:
npm install --save-dev @types/nodeOr add to tsconfig.json:
{
"compilerOptions": {
"skipLibCheck": true
}
}Debugging
Enable Debug Mode
Check what's happening under the hood:
-
Check icondev.json:
cat icondev.json | jq . -
Verify config in code:
// Node.js only import fs from 'fs' const config = JSON.parse(fs.readFileSync('icondev.json', 'utf-8')) console.log(config) -
Test icon loading:
import { loadIcon } from 'icondev' loadIcon({ name: 'home' }) .then(result => console.log('✅ Success:', result)) .catch(error => console.error('❌ Error:', error)) -
Check available icons:
import { getAvailableIcons, hasIcon } from 'icondev' console.log('All icons:', getAvailableIcons()) console.log('Has "home":', hasIcon('home'))
Verify Configuration
Check that your icondev.json is valid:
- API Key is correct:
const config = require('./icondev.json')
console.log('API Key:', config.apiKey)
// Should start with 'pk_'- Icons array exists:
console.log('Icon count:', config.icons?.length || 0)
console.log('First icon:', config.icons?.[0])- CDN URL is accessible:
// Test in browser or Node.js
fetch('https://cdn.icon.dev/health')
.then(res => console.log('CDN Status:', res.status))
.catch(err => console.error('CDN Error:', err))Getting Help
If you're still stuck:
Before reporting an issue, please provide:
- Error message (full stack trace)
- Browser and version (if browser issue)
- Framework and version (Next.js, Nuxt, etc.)
- Your
icondev.jsonstructure (remove sensitive data) - Steps to reproduce
Contact:
- 📧 Email: support@icon.dev
- 📚 Docs: https://icon.dev/docs
- 💬 GitHub: https://github.com/icondev/icondev
Next Steps
- Getting Started - Setup guide
- API Reference - Full API documentation
- Best Practices - Performance tips