Third-party libraries
Import React components from npm packages, such as charts and design system components, into your MDX pages.
Third-party libraries require an Enterprise plan
Use components from npm packages, such as charts or your own design system, in your MDX pages. When you deploy, Mintlify installs the packages in your lockfile, renders each component to HTML, and loads its JavaScript in the browser.
Only install packages you trust. Package code runs with the same access as the page, including the page content and anything the reader’s browser stores for your site. It can make network requests to any server. Removing a package or rolling back a deployment doesn’t stop code that already loaded in a reader’s browser.
Third-party libraries aren’t available on sites that use authentication or personalization. Deployments that include packages in docs.json fail on those sites, including their preview deployments.
On a site without authentication or personalization, preview deployments that require organization authentication or a password still deploy. Mintlify doesn’t build your packages for those previews, so components from your packages don’t render on them.
While your site uses third-party libraries, you can’t turn on authentication, personalization, or access restrictions for preview deployments.
Examples
The components in this section come from npm packages that this site installs.
Interactive charts
Hover over either chart, and both tooltips follow the same date. Drag the handles under the latency chart to narrow the date range for both charts. Built with recharts
import { useId } from "react" ;
import {
Area ,
AreaChart ,
Brush ,
CartesianGrid ,
Line ,
LineChart ,
ResponsiveContainer ,
Tooltip ,
XAxis ,
YAxis ,
} from "recharts" ;
const data = [
{ day: "Oct 1" , requests: 16600 , latency: 142 },
{ day: "Oct 2" , requests: 21900 , latency: 154 },
{ day: "Oct 3" , requests: 18800 , latency: 148 },
{ day: "Oct 4" , requests: 25800 , latency: 182 },
{ day: "Oct 5" , requests: 28200 , latency: 176 },
{ day: "Oct 6" , requests: 19700 , latency: 136 },
{ day: "Oct 7" , requests: 22900 , latency: 151 },
{ day: "Oct 8" , requests: 24100 , latency: 158 },
{ day: "Oct 9" , requests: 26400 , latency: 171 },
{ day: "Oct 10" , requests: 21300 , latency: 149 },
];
const tick = { fill: "currentColor" , fillOpacity: 0.6 , fontSize: 12 };
const grid = { stroke: "currentColor" , strokeOpacity: 0.15 };
const tooltip = {
contentStyle: {
backgroundColor: "rgba(17, 24, 39, 0.92)" ,
border: "none" ,
borderRadius: 8 ,
color: "#fff" ,
fontSize: 12 ,
},
itemStyle: { color: "#fff" },
isAnimationActive: false ,
};
export const SynchronizedCharts = () => {
const syncId = useId ();
return (
< div style = { { width: "100%" }} >
< div style = { { width: "100%" , height: 180 }} >
< ResponsiveContainer width = "100%" height = "100%" minWidth = { 0 } >
< AreaChart data = { data } syncId = { syncId } accessibilityLayer >
< CartesianGrid vertical = { false } { ... grid } />
< XAxis dataKey = "day" tick = { tick } stroke = "currentColor" strokeOpacity = { 0.3 } />
< YAxis width = { 72 } tick = { tick } stroke = "currentColor" strokeOpacity = { 0.3 } />
< Tooltip { ... tooltip } />
< Area
dataKey = "requests"
name = "Requests"
type = "monotone"
stroke = "#166E3F"
fill = "#26BD6C"
fillOpacity = { 0.25 }
isAnimationActive = { false }
/>
</ AreaChart >
</ ResponsiveContainer >
</ div >
< div style = { { width: "100%" , height: 230 }} >
< ResponsiveContainer width = "100%" height = "100%" minWidth = { 0 } >
< LineChart data = { data } syncId = { syncId } accessibilityLayer >
< CartesianGrid vertical = { false } { ... grid } />
< XAxis dataKey = "day" tick = { tick } stroke = "currentColor" strokeOpacity = { 0.3 } />
< YAxis
width = { 72 }
domain = { [0 , 240 ]}
tick = { tick }
stroke = "currentColor"
strokeOpacity = { 0.3 }
tickFormatter = { (value ) => ` ${ value } ms` }
/>
< Tooltip { ... tooltip } />
< Line
dataKey = "latency"
name = "Latency (ms)"
type = "monotone"
stroke = "#E0803A"
strokeWidth = { 2 }
dot = { false }
isAnimationActive = { false }
/>
< Brush
dataKey = "day"
height = { 28 }
travellerWidth = { 10 }
stroke = "#26BD6C"
fill = "transparent"
ariaLabel = "Visible date range for both charts"
/>
</ LineChart >
</ ResponsiveContainer >
</ div >
</ div >
);
};
import { useId } from "react";
import {
Area,
AreaChart,
Brush,
CartesianGrid,
Line,
LineChart,
ResponsiveContainer,
Tooltip,
XAxis,
YAxis,
} from "recharts";
const data = [
{ day: "Oct 1", requests: 16600, latency: 142 },
{ day: "Oct 2", requests: 21900, latency: 154 },
{ day: "Oct 3", requests: 18800, latency: 148 },
{ day: "Oct 4", requests: 25800, latency: 182 },
{ day: "Oct 5", requests: 28200, latency: 176 },
{ day: "Oct 6", requests: 19700, latency: 136 },
{ day: "Oct 7", requests: 22900, latency: 151 },
{ day: "Oct 8", requests: 24100, latency: 158 },
{ day: "Oct 9", requests: 26400, latency: 171 },
{ day: "Oct 10", requests: 21300, latency: 149 },
];
const tick = { fill: "currentColor", fillOpacity: 0.6, fontSize: 12 };
const grid = { stroke: "currentColor", strokeOpacity: 0.15 };
const tooltip = {
contentStyle: {
backgroundColor: "rgba(17, 24, 39, 0.92)",
border: "none",
borderRadius: 8,
color: "#fff",
fontSize: 12,
},
itemStyle: { color: "#fff" },
isAnimationActive: false,
};
export const SynchronizedCharts = () => {
const syncId = useId();
return (
<div style={{ width: "100%" }}>
<div style={{ width: "100%", height: 180 }}>
<ResponsiveContainer width="100%" height="100%" minWidth={0}>
<AreaChart data={data} syncId={syncId} accessibilityLayer>
<CartesianGrid vertical={false} {...grid} />
<XAxis dataKey="day" tick={tick} stroke="currentColor" strokeOpacity={0.3} />
<YAxis width={72} tick={tick} stroke="currentColor" strokeOpacity={0.3} />
<Tooltip {...tooltip} />
<Area
dataKey="requests"
name="Requests"
type="monotone"
stroke="#166E3F"
fill="#26BD6C"
fillOpacity={0.25}
isAnimationActive={false}
/>
</AreaChart>
</ResponsiveContainer>
</div>
<div style={{ width: "100%", height: 230 }}>
<ResponsiveContainer width="100%" height="100%" minWidth={0}>
<LineChart data={data} syncId={syncId} accessibilityLayer>
<CartesianGrid vertical={false} {...grid} />
<XAxis dataKey="day" tick={tick} stroke="currentColor" strokeOpacity={0.3} />
<YAxis
width={72}
domain={[0, 240]}
tick={tick}
stroke="currentColor"
strokeOpacity={0.3}
tickFormatter={(value) => `${value} ms`}
/>
<Tooltip {...tooltip} />
<Line
dataKey="latency"
name="Latency (ms)"
type="monotone"
stroke="#E0803A"
strokeWidth={2}
dot={false}
isAnimationActive={false}
/>
<Brush
dataKey="day"
height={28}
travellerWidth={10}
stroke="#26BD6C"
fill="transparent"
ariaLabel="Visible date range for both charts"
/>
</LineChart>
</ResponsiveContainer>
</div>
</div>
);
};Visual effects
Change the palette, shape, and pixel size of an animated shader. Built with @paper-design/shaders-react
import { useEffect , useId , useState } from "react" ;
import { Dithering } from "@paper-design/shaders-react" ;
const palettes = [
{ name: "Mint" , back: "#0b1f14" , front: "#26BD6C" },
{ name: "Violet" , back: "#10091f" , front: "#d9c6ff" },
{ name: "Ember" , back: "#1f0d06" , front: "#ffb37a" },
];
const shapes = ["sphere" , "warp" , "ripple" , "swirl" ];
const control = {
font: "inherit" ,
fontSize: 13 ,
padding: "4px 10px" ,
borderRadius: 6 ,
border: "1px solid rgba(127, 127, 127, 0.4)" ,
background: "transparent" ,
color: "inherit" ,
cursor: "pointer" ,
};
export const DitheringExample = () => {
const shapeId = useId ();
const [palette , setPalette ] = useState (palettes [0 ]);
const [shape , setShape ] = useState ("sphere" );
const [size , setSize ] = useState (3 );
const [paused , setPaused ] = useState (false );
// Hold the shader still until the reduced-motion check runs after mount.
const [motionChecked , setMotionChecked ] = useState (false );
useEffect (() => {
if (window .matchMedia ("(prefers-reduced-motion: reduce)" ).matches ) {
setPaused (true );
}
setMotionChecked (true );
}, []);
return (
< div style = { { width: "100%" }} >
< Dithering
width = "100%"
height = { 320 }
speed = { paused || ! motionChecked ? 0 : 0.4 }
scale = { 0.6 }
maxPixelCount = { 2000000 }
colorBack = { palette .back }
colorFront = { palette .front }
shape = { shape }
type = "4x4"
size = { size }
style = { { borderRadius: 12 , overflow: "hidden" , backgroundColor: palette .back }}
/>
< div
style = { {
display: "flex" ,
flexWrap: "wrap" ,
alignItems: "center" ,
gap: 8 ,
marginTop: 12 ,
marginBottom: 16 ,
fontSize: 13 ,
}}
>
{ palettes .map ((p ) => (
< button
key = { p .name }
type = "button"
aria-pressed = { palette .name === p .name }
onClick = { () => setPalette (p )}
style = { {
... control ,
borderColor: palette .name === p .name ? p .front : "rgba(127, 127, 127, 0.4)" ,
}}
>
{ p .name }
</ button >
))}
< label htmlFor = { shapeId } style = { { marginLeft: 8 }} >
Shape
</ label >
< select
id = { shapeId }
value = { shape }
onChange = { (e ) => setShape (e .target .value )}
style = { control }
>
{ shapes .map ((s ) => (
< option key = { s } value = { s } >
{ s }
</ option >
))}
</ select >
< label style = { { display: "flex" , alignItems: "center" , gap: 6 , marginLeft: 8 }} >
Pixel size
< input
type = "range"
min = { 1 }
max = { 8 }
value = { size }
style = { { accentColor: palette .front }}
onChange = { (e ) => setSize (Number (e .target .value ))}
/>
</ label >
< button
type = "button"
onClick = { () => setPaused (! paused )}
style = { { ... control , marginLeft: "auto" }}
>
{ paused ? "Play" : "Pause" }
</ button >
</ div >
</ div >
);
};
import { useEffect, useId, useState } from "react";
import { Dithering } from "@paper-design/shaders-react";
const palettes = [
{ name: "Mint", back: "#0b1f14", front: "#26BD6C" },
{ name: "Violet", back: "#10091f", front: "#d9c6ff" },
{ name: "Ember", back: "#1f0d06", front: "#ffb37a" },
];
const shapes = ["sphere", "warp", "ripple", "swirl"];
const control = {
font: "inherit",
fontSize: 13,
padding: "4px 10px",
borderRadius: 6,
border: "1px solid rgba(127, 127, 127, 0.4)",
background: "transparent",
color: "inherit",
cursor: "pointer",
};
export const DitheringExample = () => {
const shapeId = useId();
const [palette, setPalette] = useState(palettes[0]);
const [shape, setShape] = useState("sphere");
const [size, setSize] = useState(3);
const [paused, setPaused] = useState(false);
// Hold the shader still until the reduced-motion check runs after mount.
const [motionChecked, setMotionChecked] = useState(false);
useEffect(() => {
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
setPaused(true);
}
setMotionChecked(true);
}, []);
return (
<div style={{ width: "100%" }}>
<Dithering
width="100%"
height={320}
speed={paused || !motionChecked ? 0 : 0.4}
scale={0.6}
maxPixelCount={2000000}
colorBack={palette.back}
colorFront={palette.front}
shape={shape}
type="4x4"
size={size}
style={{ borderRadius: 12, overflow: "hidden", backgroundColor: palette.back }}
/>
<div
style={{
display: "flex",
flexWrap: "wrap",
alignItems: "center",
gap: 8,
marginTop: 12,
marginBottom: 16,
fontSize: 13,
}}
>
{palettes.map((p) => (
<button
key={p.name}
type="button"
aria-pressed={palette.name === p.name}
onClick={() => setPalette(p)}
style={{
...control,
borderColor: palette.name === p.name ? p.front : "rgba(127, 127, 127, 0.4)",
}}
>
{p.name}
</button>
))}
<label htmlFor={shapeId} style={{ marginLeft: 8 }}>
Shape
</label>
<select
id={shapeId}
value={shape}
onChange={(e) => setShape(e.target.value)}
style={control}
>
{shapes.map((s) => (
<option key={s} value={s}>
{s}
</option>
))}
</select>
<label style={{ display: "flex", alignItems: "center", gap: 6, marginLeft: 8 }}>
Pixel size
<input
type="range"
min={1}
max={8}
value={size}
style={{ accentColor: palette.front }}
onChange={(e) => setSize(Number(e.target.value))}
/>
</label>
<button
type="button"
onClick={() => setPaused(!paused)}
style={{ ...control, marginLeft: "auto" }}
>
{paused ? "Play" : "Pause"}
</button>
</div>
</div>
);
};More examples
These pages import other npm packages into a Mintlify site. Each one includes a live demo and the code that renders it.
Arrange and connect the steps of a workflow with React Flow.
Insert headings, lists, and code blocks from the keyboard with Tiptap.
Filter a list and select several labels with a Base UI combobox.
Adjust the stiffness, damping, and mass of a spring with Motion.
Add a package
- List your dependencies
Create a
package.jsonfile in the same folder as yourdocs.jsonfile. List every package you import underdependencies, includingreactandreact-dom.package.json{{ "private": true, "dependencies": { "@acme/charts": "^2.0.0", "react": "^18.3.1", "react-dom": "^18.3.1" } }"private" :true ,"dependencies" : {"@acme/charts" :"^2.0.0" ,"react" :"^18.3.1" ,"react-dom" :"^18.3.1" } }Mintlify installs only
dependencies. Packages listed only indevDependenciesorpeerDependenciesaren’t available to your pages. - Commit a lockfile
Install your dependencies and commit the lockfile next to
package.json.pnpm installpnpm install Mintlify installs the exact versions in your lockfile. It supports
pnpm-lock.yamlversion 9 from pnpm andpackage-lock.jsonfrom npm. Yarn and Bun lockfiles aren’t supported. - Turn on packages
Add the
packageskey to yourdocs.json. An empty object turns packages on with the default settings.docs.json{{ "packages": {} }"packages" : {} } - Import a component
Create a component in your
snippetsfolder that imports from the package.snippets/requests-chart.jsximport { LineChart } from "@acme/charts"; const data = [ { day: "Mon", requests: 120 }, { day: "Tue", requests: 180 }, { day: "Wed", requests: 150 }, ]; export const RequestsChart = () => ( <LineChart data={data} x="day" y="requests" height={240} /> );import {LineChart }from "@acme/charts" ;const data = [ {day: "Mon" ,requests: 120 }, {day: "Tue" ,requests: 180 }, {day: "Wed" ,requests: 150 }, ];export const RequestsChart = ()=> (< LineChart data = { data } x = "day" y = "requests" height = { 240 } /> );Then import it into a page:
import { RequestsChart } from "/snippets/requests-chart.jsx"; <RequestsChart />import {RequestsChart }from "/snippets/requests-chart.jsx" ;< RequestsChart /> - Deploy
Push your changes. If a package can’t be installed or built, the deployment fails with an error that names the package and the problem.
To preview locally, install your dependencies and then run mint dev from the folder with your docs.json file.
Use package components
You can also import components directly from a package into an MDX page:
import { Tooltip } from "@acme/ui" ;
< Tooltip content = "Requests per day" > Usage</ Tooltip >
import { Tooltip } from "@acme/ui";
<Tooltip content="Requests per day">Usage</Tooltip>- Place package components on their own lines. They don’t work inside a paragraph, a table cell, or inline text.
- Pass strings, numbers, and booleans as props directly. For functions, arrays, objects, or JSX props, write a wrapper component in your
snippetsfolder, like the chart in Add a package, and pass the values there. - Markdown inside a package component renders as plain HTML. Mintlify components, such as callouts and cards, don’t render inside a package component.
Load package styles
Components can import their own CSS. To load a stylesheet that a package ships separately, add its path inside the installed package to packages.css:
{
"packages" : {
"css" : ["@acme/ui/dist/styles.css" ]
}
}
{
"packages": {
"css": ["@acme/ui/dist/styles.css"]
}
}Packages must ship compiled CSS. Mintlify doesn’t run CSS build tools or plugins on package code, and doesn’t support CSS modules. Package stylesheets can’t load fonts or images from remote URLs. Load fonts with your site’s font settings instead.
Wrap components in a provider
If your components need a theme or context provider, export a Provider component from a snippet and set packages.provider to its path:
{
"packages" : {
"provider" : "/snippets/provider.jsx"
}
}
{
"packages": {
"provider": "/snippets/provider.jsx"
}
}import { ThemeProvider } from "@acme/ui" ;
export const Provider = ({ children }) => < ThemeProvider > { children } </ ThemeProvider > ;
import { ThemeProvider } from "@acme/ui";
export const Provider = ({ children }) => <ThemeProvider>{children}</ThemeProvider>;The provider wraps each package component separately. Components don’t share state through it.
Install from another registry
Unscoped packages install from the public npm registry. To install a scope from a different registry, map the scope to the registry’s URL in packages.registries:
{
"packages" : {
"registries" : {
"@acme" : "https://npm.acme.com/"
}
}
}
{
"packages": {
"registries": {
"@acme": "https://npm.acme.com/"
}
}
}The registry must use HTTPS on the default port and be reachable from the public internet without credentials.
Limitations
- Dependency sources: Dependencies must be registry versions, version ranges, or tags. Git URLs, local paths,
file:,link:,workspace:, andnpm:aliases aren’t supported. - Install scripts: Packages install without running install scripts such as
postinstall. Packages that need them, or that need native binaries, don’t work. - Size: A deployment’s package output can include up to 1,000 files, 8 MB per file, 40 MB in total, and 5 MB gzipped. Packages that load large sets of modules at runtime, such as dynamic icon maps, can go over the file limit.
- Server rendering: Each component must render within three seconds on the server. A component that fails or times out renders only in the browser, so it’s missing from the page’s HTML.
- Search and AI: Search, the assistant, and Markdown exports use your MDX source, not the content a component renders. Keep important reference content in your MDX text.
- Web editor: The web editor preview doesn’t render package components.
To stop using packages, remove packages from your docs.json file and redeploy.