@worldkit/flags
v1.0.3
Published
Modular flag emoji generator and SVG assets provider
Maintainers
Readme
🏁 @worldkit/flags
Fast Unicode flag emoji generator and SVG flag helper for JavaScript & TypeScript.
Generate Unicode country flag emojis and clean vector SVG flag URLs for any country ISO2 code.
📚 Full Documentation: https://worldkit.in/docs/flags
⚡ Features
- 🎌 Unicode Flag Emoji: Algorithmic flag code point conversion (e.g.
"JP"->"🇯🇵"). - 🖼️ SVG Flag Helpers: High-res vector SVG CDN URLs for custom image rendering.
- 🚀 Zero Latency: Zero dependencies and zero asset bundle bloat (~0.8 KB gzipped).
📦 Install
npm install @worldkit/flags
# or
pnpm add @worldkit/flags
# or
yarn add @worldkit/flags💡 Usage
import { flagEmoji, flagSvg } from "@worldkit/flags";
// 1. Generate Unicode Flag Emoji from Country ISO2
console.log(flagEmoji("JP")); // "🇯🇵"
console.log(flagEmoji("US")); // "🇺🇸"
console.log(flagEmoji("IN")); // "🇮🇳"
console.log(flagEmoji("DE")); // "🇩🇪"
// 2. Get Vector SVG Flag CDN URL
console.log(flagSvg("jp")); // "https://flagcdn.com/jp.svg"
console.log(flagSvg("us")); // "https://flagcdn.com/us.svg"📖 API Reference
flagEmoji(countryIso2: string): string
Generates a 2-character Unicode regional indicator flag emoji string for valid ISO2 codes.
flagSvg(countryIso2: string): string
Returns an optimized vector SVG CDN URL for the specified country ISO2 code.
📐 TypeScript Support
Includes strict TypeScript declarations out of the box.
🔗 Related Packages
Explore the rest of the WorldKit ecosystem:
@worldkit/core- Unified global data facade.@worldkit/countries- 250+ country dataset.@worldkit/react- React<CountrySelect showFlag={true} />component.
📜 License
MIT © WorldKit
