Mantle Icons Migration Guide
@ngrok/mantle no longer takes @phosphor-icons/react as a peer dependency. Its icons now come from @ngrok/mantle-icons, a fork of Phosphor Icons. Each icon is a plain SVG component with no React context and no "use client", so it renders in a React Server Component and ships no JavaScript to the browser. Each weight is its own component and module: CheckBoldIcon from @ngrok/mantle-icons/CheckBold replaces <CheckIcon weight="bold" />. There is no weight prop and no IconContext. This guide moves a codebase from @phosphor-icons/react to @ngrok/mantle-icons.
TL;DR: Change each @phosphor-icons/react/<Name> import to @ngrok/mantle-icons/<Name>, and each import type from @phosphor-icons/react to @ngrok/mantle-icons. Replace <CheckIcon weight="bold" /> with <CheckBoldIcon />, imported from @ngrok/mantle-icons/CheckBold, and delete weight="regular". Then replace @phosphor-icons/react with @ngrok/mantle-icons in package.json.
Codemod
From a mantle checkout:
In a project that installs @ngrok/mantle:
The rules apply steps 2 to 4. They move each icon import and each import type from the barrel. On an icon with a literal weight ("bold", 'bold', or {"bold"}), they rename the element to the weight component, add its import, and delete the prop. They delete weight="regular". The rules read an icon through its import, under its own *Icon name. An aliased import (import { CheckIcon as Check }), a computed weight, an icon passed as a value with a weight, a value import from the barrel, and IconContext stay manual: steps 5 to 7. The rules keep the import of an icon whose every element took a weight, so step 8 removes the imports the linter reports unused. The codemod can run again: a migrated icon has no weight to match. Pass --dry-run to print the rewrites first, and run your formatter after the rewrite.
You are an agent migrating a codebase. Do this:
- Find every import from
@phosphor-icons/react: the icon modules (@phosphor-icons/react/Check), the barrel (@phosphor-icons/react), and thessranddistpaths. - Change each icon import to the same name under
@ngrok/mantle-icons:import { CheckIcon } from "@phosphor-icons/react/Check"becomesimport { CheckIcon } from "@ngrok/mantle-icons/Check". Thessranddist/csrpaths become the same@ngrok/mantle-icons/<Name>path. - Change each
import type { Icon, IconProps, IconWeight } from "@phosphor-icons/react"to@ngrok/mantle-icons. The names stay. - For each icon element with a literal
weight, render the weight component:<CheckIcon weight="bold" />becomes<CheckBoldIcon />, imported from@ngrok/mantle-icons/CheckBold. The suffixes areThin,Light,Bold,Fill, andDuotone. Deleteweight="regular": the component without a suffix is the regular weight. - For a computed
weight, render one component for each weight:<MicrophoneIcon weight={on ? "fill" : "regular"} />becomes{on ? <MicrophoneFillIcon /> : <MicrophoneIcon />}. For an icon passed as a value and rendered with aweight(<item.icon weight="fill" />), pass the weight component as the value and delete the prop. - Rename an aliased import by hand, the same as steps 2 and 4:
import { WarningIcon as Warning }with<Warning weight="fill" />becomesimport { WarningFillIcon as Warning } from "@ngrok/mantle-icons/WarningFill"with<Warning />. - Delete each
IconContext.Provider, and set itsweighton each icon inside it (step 4), itssizeandcolorwithclassName(size-4,text-muted) or thesizeandcolorprops, and itsmirroredwith themirroredprop. Replace a value import from the barrel (import { CheckIcon } from "@phosphor-icons/react") with the icon's own module, as in step 2. - Replace
@phosphor-icons/reactwith@ngrok/mantle-iconsinpackage.json(pnpm add -E @ngrok/mantle-icons). Remove@phosphor-icons/reactfrompackage.json, and from any bundler setting that names it, such as Vite'sssr.noExternaloroptimizeDeps. RemovemantlePhosphorPrunePlugin()from the Vite config: each weight is its own module, so a bundle holds only the weights it renders. - In tests:
- A test that renders an icon with
weightrenders the weight component, the same as step 4:<CheckIcon weight="bold" />becomes<CheckBoldIcon />. - A test that reads the rendered
<svg>reads the same markup: the paths,viewBox,width,height, andfillare the same as@phosphor-icons/reactrendered.
- A test that renders an icon with
- After editing, run the project's formatter, linter (which removes the imports left unused by step 4), type checker, and tests.
Why a component for each weight? Each
@phosphor-icons/reacticon holds the paths of all six weights and readsIconContext, a React context, so a bundle ships every weight and the icon can only render as client code. A component for each weight holds one set of paths and reads no context, so a bundle holds only what a page renders, and the icon renders in a React Server Component with no client JavaScript.
Before → after
An icon at the regular weight
An icon with a weight
A computed weight
A prop that takes an icon
Edge cases & gotchas
- The
ref,className,alt,color,size, andmirroredprops stay. Each icon takes every<svg>attribute. - An icon in a server component stays server code. A module that imports an icon no longer needs
"use client"for it. Keep the directive when the module has its own hooks or event handlers. - Mantle's own icons ignore
IconContext. AIconContext.Provideraround mantle parts changed nothing you can rely on before, and changes nothing now.
How to verify
Search the codebase for @phosphor-icons/react and weight= on icons: nothing should remain. Run the formatter, the linter, the type checker, and the tests (see step 9).