Install
Component source copied into your app, or the npm package.
React 18+, Node.js 18+, TypeScript 5+ recommended.
Choose your path
Pick one and follow only its commands. Both ship the same components.
Source
Copies the components you name into your app. No account, no key. Each run writes the components plus what they import to src/fragments/ui, the globals stylesheet, and .fragments/registry-lock.json, then prints the packages to add.
npx @usefragments/cli add button card checkbox alert
# then the line it prints, for example
pnpm add @base-ui/reactImports use the @/* → src/* alias. Without one, pass --to and --import-path "./fragments/ui" on the first run. Later runs keep the lockfile's target.
import "@/fragments/ui/styles/globals.scss";
import type { ReactNode } from "react";
import { ThemeProvider, TooltipProvider, ToastProvider } from "@/fragments/ui";
function App({ children }: { children: ReactNode }) {
return (
<ThemeProvider defaultMode="system">
<TooltipProvider>
<ToastProvider>{children}</ToastProvider>
</TooltipProvider>
</ThemeProvider>
);
}npx @usefragments/cli add button --registry acme/design-system. Connect a workspace to get a key. Every other command: Registry commands.Set up your framework
Vite
Import the stylesheet from your application entry file.
With a configured
@/*alias, source installs use@/fragments/ui/styles/globals.scss.Without an alias, install with
--import-path "./fragments/ui"and import./fragments/ui/styles/globals.scssfromsrc/App.tsx.Package installs use
@usefragments/ui/styles.Next.js
Current Next.js releases consume the package directly.
If your version reports an untranspiled-package error or omits the stylesheet, enable package transpilation:
next.config.tsconst nextConfig = { transpilePackages: ['@usefragments/ui'], }; export default nextConfig;Import styles in
app/layout.tsx.Set
suppressHydrationWarningon<html>.Client-only UI needs
'use client'in the rendering file.Migrating from npm? Runnpx @usefragments/cli registry migrate. Details: registry migrate.Render your first component
Compound components use dot notation, such as
Card.Header. Use the import path for your installation method.import { Button, Card, Input, Stack } from "@/fragments/ui"; function MyComponent() { return ( <Card> <Card.Header> <Card.Title>Welcome</Card.Title> </Card.Header> <Card.Body> <Stack gap="sm"> <Input placeholder="Enter your name" /> <Button>Submit</Button> </Stack> </Card.Body> </Card> ); }
Theming
For a source install, set seeds with SCSS @use ... with():
@use "@/fragments/ui/styles/globals.scss" with (
$fui-brand: #6366f1,
$fui-radius-style: "rounded"
);This SCSS import path requires sass as a dev dependency in the consumer build.
Toggle with ThemeToggle or useTheme.
AI tooling (MCP)
Connect to the hosted endpoint at https://app.usefragments.com/api/mcp with OAuth. See the MCP guide for supported tools.
{
"mcpServers": {
"fragments": {
"url": "https://app.usefragments.com/api/mcp"
}
}
}Registry commands
add copies source from the public usefragments-ui registry by default. --registry org/name selects a registry you published from Fragments Cloud (workspace key); --from or FRAGMENTS_UI_REGISTRY_ARTIFACT_URL points at a local or self-hosted artifact. npx @usefragments/cli check proves installed source against the lockfile. See the CLI reference for all flags.
add
Name components (any case), or take everything with --all. The first run picks the target from the registry's install profile; later runs keep the lockfile's:
npx @usefragments/cli add button card
npx @usefragments/cli add --all
npx @usefragments/cli add button --registry acme/design-system
npx @usefragments/cli add button --to src/fragments/ui --import-path "@/fragments/ui"status
Inspect the lockfile and installed source state:
npx @usefragments/cli registry statusdiff
Compare installed source against a registry artifact:
npx @usefragments/cli registry diffsync
Refresh installed source using the existing lockfile selection:
npx @usefragments/cli registry syncmigrate
Convert an existing @usefragments/ui app to registry source. Preview first:
npx @usefragments/cli registry migrate --dry-run
npx @usefragments/cli registry migrateMigrate installs registry source and rewrites package imports to @/fragments/ui. It updates simple Next.js transpilePackages, and removes the npm UI package unless you pass --keep-package.
Lockfile and drift
npx @usefragments/cli add writes source plus .fragments/registry-lock.json. The lockfile pins the artifact version and file hashes so npx @usefragments/cli check can prove committed source still matches the registry. Drift means local files no longer match the lockfile. Inspect drift with npx @usefragments/cli registry status and npx @usefragments/cli registry diff, then refresh with npx @usefragments/cli registry sync.
src/fragments/ui. Change selection or refresh through the registry commands above.Next steps
- ComponentsBrowse the catalog — examples, props APIs, and usage guidelines.
- Fragments CloudThe same contract, required to merge.
- CLI referenceEvery registry flag and option.