Bundle Size
Much smaller with tree-shaking (~950 bytes per imported flag vs. 200 KB+)
Quick guide for migrating from react-circle-flags to @sankyu/react-circle-flags.
Bundle Size
Much smaller with tree-shaking (~950 bytes per imported flag vs. 200 KB+)
TypeScript
Full type definitions with autocomplete for 400+ flags
Offline-first
Inline SVG components with no external requests (works offline)
Replace react-circle-flags runtime loader with tree-shakeable flag components.
import { FlagCn, FlagUs } from '@sankyu/react-circle-flags'
export function Header() { return ( <div> <FlagUs width={35} height={35} /> <FlagCn width={35} height={35} /> </div> )}react-circle-flags uses string sizes like height="35". This library uses numbers: height={35}.className, style, event handlers, etc.).If country codes come from runtime data (API/user input), you have two offline-first options.
import { FlagCn, FlagGb, FlagUs } from '@sankyu/react-circle-flags'
const FLAGS = { cn: FlagCn, gb: FlagGb, us: FlagUs } as const
export function CountryFlag({ code }: { code: string }) { const normalized = code.toLowerCase() const Flag = FLAGS[normalized as keyof typeof FLAGS] return Flag ? <Flag width={32} height={32} /> : <span>{code.toUpperCase()}</span>}import { DynamicFlag } from '@sankyu/react-circle-flags'
export function CountryFlag({ code }: { code: string }) { return <DynamicFlag code={code} width={32} height={32} />}| Approach | Bundle Size | Network | Offline |
|---|---|---|---|
react-circle-flags | ~200 KB+ | None | ✅ |
| Named imports (3 flags) | ~2.8 KB | None | ✅ |
| DynamicFlag | ~600 KB | None | ✅ |
npm uninstall react-circle-flagsnpm install @sankyu/react-circle-flagspnpm remove react-circle-flagspnpm add @sankyu/react-circle-flagsyarn remove react-circle-flagsyarn add @sankyu/react-circle-flags