CLI
Set up Ghostly, generate loading states, and diagnose issues from the command line.
The Ghostly CLI automates setup, generates loading.tsx files by analyzing your components, and checks your project health.
npx @ghostly-ui/cli --helpghostly init
Interactive setup wizard. Detects your package manager, installs packages, adds CSS import, configures GhostlyProvider and Tailwind plugin.
npx @ghostly-ui/cli initWhat it does:
- Installs
@ghostly-ui/coreand@ghostly-ui/react - Adds
@import '@ghostly-ui/core/css'to yourglobals.css - Wraps
{children}with<GhostlyProvider>in yourlayout.tsx - (Optional) Adds the Tailwind plugin to your config
You can run init at any time — it skips steps that are already done.
ghostly add loading
Scans your Next.js App Router pages, analyzes which components they import, and generates loading.tsx files with the correct Ghostly wrappers.
Interactive mode (recommended)
npx @ghostly-ui/cli add loadingThis scans all routes, shows which ones are missing loading.tsx, and lets you select which to generate.
Specific route
npx @ghostly-ui/cli add loading app/dashboardHow it works
- Finds
page.tsxin the route directory - Extracts component imports (detects PascalCase names)
- Detects list patterns (components used inside
.map()) - Generates
loading.tsxwith<Ghostly>for single components and<GhostlyList>for lists - Lets you confirm/select which components to include
Example output
For a page that imports UserProfile and maps over ProductCard:
import { Ghostly, GhostlyList } from '@ghostly-ui/react'
import { UserProfile } from '@/components/user-profile'
import { ProductCard } from '@/components/product-card'
export default function Loading() {
return (
<div className="space-y-6">
<Ghostly loading={true}>
<UserProfile />
</Ghostly>
<GhostlyList loading={true} count={4} item={<ProductCard />}>
<></>
</GhostlyList>
</div>
)
}ghostly doctor
Health check that verifies your Ghostly setup is correct.
npx @ghostly-ui/cli doctorChecks:
- Packages installed (
@ghostly-ui/core,@ghostly-ui/react) - CSS imported in
globals.css - React version (>= 18)
- GhostlyProvider in layout
loading.tsxcoverage (how many routes have one)- Tailwind plugin configured
- Built CSS exists in
node_modules
Example output:
ghostly — Health check
✓ package.json: Found
✓ @ghostly-ui/core: Installed (^0.2.4)
✓ @ghostly-ui/react: Installed (^0.2.4)
✓ CSS import: Found in app/globals.css
✓ React version: ^19.0.0
✓ Framework: Next.js detected
✓ App Router: Found at app/
✓ GhostlyProvider: Found in app/layout.tsx
! loading.tsx coverage: 3/5 routes have loading.tsx
✓ Tailwind plugin: Found in tailwind.config.ts
✓ Built CSS: ghostly.css found in node_modules
10/11 checks passed. Fix the issues above.