npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

iconify-nextjs-ssr

v0.0.3

Published

A lightweight utility package for rendering iconify/svg icons on nextjs server and removes flickering on load.

Readme

🖼️ iconify-nextjs-ssr

A utility to render Iconify icons server-side in Next.js — with no flickering, no hydration mismatch, and optional dimension stripping.

Note:
StaticIconifyIcon can be used as a drop-in replacement for Icon from @iconify/react.
You can simply swap your imports:

// Before
import { Icon } from "@iconify/react";

// After
import { StaticIconifyIcon as Icon } from "iconify-nextjs-ssr";
// or
import Icon from "iconify-nextjs-ssr";

The API is compatible for most common use cases.



✨ Features

  • ✅ Fully server-side rendering (SSR) compatible. Can be used inside client component in nextjs app router as well by passing it as props See
  • ✅ Eliminates client-side flicker
  • ✅ Optionally remove width and height attributes
  • ✅ Supports custom Iconify hosts
  • ✅ Lightweight

📦 Installation

pnpm add iconify-nextjs-ssr
# or
npm install iconify-nextjs-ssr
# or
yarn add iconify-nextjs-ssr

🧠 Usage

In a Server Component (App Router)

import StaticIconifyIcon from "iconify-nextjs-ssr";

export default async function Page() {
  return (
    <div className="p-4">
      <h1 className="text-xl font-bold mb-4">Rendered on the Server</h1>
      <StaticIconifyIcon icon="logos:react" className="w-12 h-12 text-blue-500" removeDimensions />
    </div>
  );
}

In a Client Component (App Router)

// icons.tsx
import StaticIconifyIcon from "iconify-nextjs-ssr";
export const skillsIcons = {
  java: <StaticIconifyIcon icon="logos:java" width={28} height={28} />,
  menu: <StaticIconifyIcon icon="logos:react" width={28} height={28} />,
};
// skills.tsx
"use client";

export default function SkillsClientComponent({
  icons,
}: {
  icons: Record<string, React.ReactNode>;
}) {
  return (
    <div className="p-4">
      <h1 className="text-xl font-bold mb-4">Rendered on the Client</h1>
      {icons.java}
      {icons.react}
    </div>
  );
}
// page.tsx
<SkillsClientComponent icons={skillsIcons}>

🧾 API Reference

Main Component

StaticIconifyIcon

Renders an Iconify SVG icon, SSR-safe.

Props:

| Prop | Type | Default | Description | | ------------------ | ------------------ | ---------------------------- | ------------------------------------------------------ | | icon | string | – (required) | Icon name in prefix:name format (e.g. logos:react) | | className | string | undefined | CSS classes applied to the <svg> | | removeDimensions | boolean | false | If true, strips width and height from the SVG | | host | string | https://api.iconify.design | Iconify API host to fetch from | | height | number \| string | undefined | Update SVG height (any units) | | width | number \| string | undefined | Update SVG width (any units) |


Utility Functions

fetchIconSvg(link: string): Promise<string | null>

Fetches the SVG string from the given SVG link. Uses force-cache for fetch caching.

transformIcon(svg: string, options): string

Transforms the SVG string:

  • Optionally removes width and height attributes (removeDimensions)
  • Optionally sets height and width
  • Optionally adds a className to the <svg>

fetchCache

A constant string "force-cache" used for fetch caching.

🧪 Example (with multiple icons)

import StaticIconifyIcon from "iconify-nextjs-ssr";

const icons = ["logos:react", "logos:java", "mdi:account"];

export default async function IconsRow() {
  return (
    <div className="flex gap-4">
      {await Promise.all(
        icons.map((icon) => <StaticIconifyIcon key={icon} icon={icon} className="w-6 h-6" />)
      )}
    </div>
  );
}

🚀 Why Not @iconify/react?

| Feature | @iconify/react | iconify-nextjs-ssr | | ----------------------- | ---------------- | -------------------- | | Client-side flicker | ❌ Yes | ✅ No | | SSR support | ❌ No | ✅ Full | | Async server rendering | ❌ No | ✅ Yes | | Fully static compatible | ❌ No | ✅ Yes | | Lightweight | ❌ No | ✅ Yes |


📂 Output Directory

This package is bundled using tsup into:

  • CommonJS: dist/main.cjs
  • ES Module: dist/main.js
  • Types: dist/main.d.ts