Getting Started
Official NPM package for React, Vue, Angular and JavaScript applications
Overview
The icondev NPM package is the official SDK for React, Vue, Angular, Svelte, and vanilla JavaScript. Load icons on-demand from Cloudflare CDN with smart caching and full TypeScript support.
Key Features:
- CDN-based loading with smart caching
- React, Vue 3, Angular, Svelte support
- Full TypeScript support
- Works with SSR (Next.js, Nuxt, Remix)
- Lightweight (~5KB core + ~2KB per adapter)
Getting Started
Install package
npm install icondevInitialize project
npx icondev initYou'll be prompted for your API key. This creates icondev.json with your project configuration.
Use in your app
import { Icon } from 'icondev/react'
function App() {
return <Icon name="home" size={24} />
}<script setup>
import { Icon } from 'icondev/vue'
</script>
<template>
<Icon name="home" :size="24" />
</template>'use client'
import { Icon } from 'icondev/react'
export default function Page() {
return <Icon name="home" size={24} />
}Icons load automatically from CDN with in-memory caching for optimal performance.
How It Works
- Run
npx icondev initto createicondev.json - Import
Iconcomponent fromicondev/reactoricondev/vue - Icons load from Cloudflare CDN on first render
- Cached in memory for instant re-renders
- In Node.js/SSR: reads from
icondev.json - In browser: fetches from CDN directly
Basic Usage
React
import { Icon } from 'icondev/react'
<Icon name="home" size={24} />
<Icon name="search" color="blue" />
<Icon name="user" className="my-icon" />Vue 3
<script setup>
import { Icon } from 'icondev/vue'
</script>
<template>
<Icon name="home" :size="24" />
<Icon name="search" color="blue" />
<Icon name="user" class="my-icon" />
</template>Core API
import { loadIcon, preloadIcons } from 'icondev'
// Load single icon
const { svg } = await loadIcon({ name: 'home' })
// Preload multiple icons
await preloadIcons(['home', 'search', 'user'])Configuration
After running npx icondev init, you'll have an icondev.json file:
{
"apiKey": "pk_...",
"projectSlug": "my-project",
"cdnUrl": "https://cdn.icon.dev",
"icons": [
{
"slug": "home",
"name": "Home",
"url": "https://cdn.icon.dev/...",
"version": "v1",
"hash": "abc123"
}
]
}Production: The icondev.json file contains your icon list and is needed for the app to work. Commit it to git, but make sure to use environment variables for sensitive keys in production (see Best Practices).
Updating Icons
When you add new icons to your project, sync your local config:
npx icondev syncThis updates icondev.json with the latest icons from your project.
Available Props
| Prop | Type | Default | Description |
|---|---|---|---|
name | string | required | Icon slug |
size | number | string | 24 | Size in pixels |
color | string | currentColor | Fill color |
stroke | string | currentColor | Stroke color |
className / class | string | - | CSS classes |
Next Steps
- API Reference - Components, hooks, and functions
- Framework Integration - Next.js, Nuxt, Remix guides
- Best Practices - Performance optimization
- Troubleshooting - Common issues