Skip to content
Discussion options

You must be logged in to vote

Hi @1chooo 👋,

You're right, the method like:

import MdAttachment from "react-icons/md/MdAttachment"; doesn't work because react-icons doesn't expose icons like that as separate modules in the default package.

To import only the icons you need without loading the full bundle in Next.js, follow this:

Instead of the default react-icons package, use:

npm install @react-icons/all-files

Then import icons like this:

import { MdAttachment } from "@react-icons/all-files/md/MdAttachment";
import { MdOutlineDevices } from "@react-icons/all-files/md/MdOutlineDevices";

This works with Next.js (including App Router) and helps optimize your bundle size by importing only what you use.

Why Not Default rea…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@1chooo
Comment options

@icyJoseph
Comment options

@1chooo
Comment options

@icyJoseph
Comment options

Answer selected by 1chooo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants