@stock-icons/stock-icons
v1.0.1
Published
React stock icon resolver and component
Downloads
186
Readme
@stock-icons/stock-icons
React+TypeScript library for resolving stock logo URLs and rendering icons.
Features
getStockLogo({ symbol, domain?, image? })with priority path: image → domain → dataset → CDN fallbackgetStockLogoCached(...)with map-based caching<StockIcon symbol='AAPL' />component with lazy loading and onError fallback- ESM+CJS build via tsup
Install
npm install @stock-icons/stock-icons
npm install reactUsage
import { StockIcon } from "@stock-icons/stock-icons";
export function Example() {
return (
<div className="flex gap-4 items-center">
<StockIcon symbol="AAPL" size={48} />
<h1>APPLE</h1>
</div>
);
}If you want getStockLogo as well, you can also do:
import { StockIcon, getStockLogo } from "@stock-icons/stock-icons";
export function ExampleWithImage() {
return (
<div className="flex gap-4 items-center">
<StockIcon symbol="AAPL" size={48} />
<img
src={getStockLogo("NFLX")}
alt="Netflix logo"
width={48}
height={48}
/>
</div>
);
}Dataset generation scripts
npm run fetch:stocks
npm run enrich:top100Output files:
stocks.jsonstocks-with-domain.json
Build
npm install
npm run build