How to Use
Step-by-step guide for adding new components to the Homokozoo library.
This guide walks you through adding a new component to Homokozoo. By the end your component will have its own docs page and be installable from the registry.
Use the existing Example component as a reference:
| File | Purpose |
|---|---|
src/components/example.tsx | Component source |
content/docs/example.mdx | Docs page (at /docs/example) |
registry.json | Registry metadata |
public/r/example.json | Generated registry artifact |
End result
Your component will be browsable at /docs/<name> and installable via npx shadcn@latest add @homok/<name>.
Component Source
Create a new file under src/components/. For a component called foo:
src/components/foo.tsx
Follow this structure:
- Define a typed props interface (e.g.
FooProps) - Export a named component function (e.g.
export function Foo(...)) - Add
'use client';only if the component uses browser APIs, Canvas, or client-only hooks
'use client';
import type { HTMLAttributes } from 'react';
export interface FooProps extends HTMLAttributes<HTMLDivElement> {
label?: string;
}
export function Foo({ label = 'Hello', ...props }: FooProps) {
return <div {...props}>{label}</div>;
}Docs Page
Create a new MDX file under content/docs/. For foo:
content/docs/foo.mdx
This automatically becomes the route /docs/foo. Every docs page must include these sections in order:
- Frontmatter —
titleanddescription - Preview — one or more
<ComponentPreview>blocks - Installation — the
<InstallationCommands>block - Usage — import snippet + example usage
- Props table — document every prop (markdown table or
<TypeTable>)
Frontmatter
---
title: Foo
description: A brief description of the Foo component.
---Imports
import { Foo } from '@/components/foo';
import CopyCommandButton from '@/components/copy-command-button';
import InstallationCommands from '@/components/installation-commands';
import ComponentPreview from '@/components/component-preview';Copy Command Button
Place right after imports — gives users a one-click copy for the install command:
<div className="flex flex-col md:flex-row items-center justify-end gap-2 mb-2">
<CopyCommandButton
copyCommand="npx shadcn@latest add @homok/foo"
command="npx shadcn@latest add @homok/foo"
/>
</div>Preview
Wrap your component in <ComponentPreview>:
<ComponentPreview title="Foo default" name="foo-default">
<Foo />
</ComponentPreview>Installation
<InstallationCommands packageName="foo" />Usage
Show the import and a minimal usage example:
import { Foo } from '@/components/foo'<Foo label="World" />Tip
Keep all docs content in English. Use Fumadocs UI components like Callout, Cards, Tabs, and Steps when they improve readability.
Registry
Install Command
Use this command format everywhere in docs:
npx shadcn@latest add @homok/fooThe CopyCommandButton and InstallationCommands components generate this automatically when given the correct packageName.
Register in registry.json
Open registry.json at the project root and add a new entry to the items array:
{
"name": "foo",
"type": "registry:component",
"title": "Foo",
"description": "A brief description of the Foo component.",
"dependencies": [],
"files": [
{
"path": "src/components/foo.tsx",
"type": "registry:component",
"target": "components/foo.tsx"
}
]
}| Field | Description |
|---|---|
name | Unique identifier (lowercase, kebab-case) |
type | registry:component for standalone components |
title | Human-readable display name |
description | Short description |
dependencies | Runtime npm dependencies (e.g. ["three"]) |
files | Array of file mappings (path → target) |
Build Artifacts
Run the build command to generate the JSON artifacts:
npm run registry:buildThis produces:
public/r/foo.json— the installable component artifactpublic/r/registry.json— updated registry index
Validate
Run a type check to make sure nothing is broken:
npm run types:checkThen verify manually:
- Start the dev server with
npm run dev - Open
/docs/foo— check that the page renders correctly - Confirm the sidebar shows your new component under Components
- Confirm the install command is correct in the docs
- Optionally test the registry endpoint:
curl http://localhost:3000/r/foo.jsonChecklist
Before merging, ensure every item is complete:
-
src/components/foo.tsxexists with typed props and named export -
content/docs/foo.mdxexists with preview, install, usage, and props sections -
registry.jsonincludes thefooentry with correct dependencies -
npm run registry:buildsucceeds andpublic/r/foo.jsonis generated -
npm run types:checkpasses - The docs page renders correctly at
/docs/foo