This guide walks you through the complete process of creating and publishing a new component in the svelte animationss.
- Create main component in
src/lib/components/magic/ - Create route in
src/routes/magic/docs/components/ - Add component to
registry.json - Build registry:
pnpm registry:build - Test component installation
- Make a PR
Create your component folder inside src/lib/components/magic/.
src/lib/components/magic/
└── your-component/
├── your-component.svelte # Main component
├── index.ts # Exports
├── types.ts # (optional) TypeScript hooks
└── use-*.svelte.ts # (optional) Composable
Create a new folder inside src/routes/magic/docs/components/ with your component name.
src/routes/magic/docs/components/your-component/
├── +page.svelte # Page component
├── docs.md # Documentation for AI/LLMs
├── data.ts # Component data (types, code, SEO, examples)
├── examples/
│ ├── preview.svelte # Main preview component
│ └── *.svelte # Additional example files
└── llms.txt/
└── +server.ts # Just use to serve docs.md as plain text - you can copy the same from other components, no need to change anything..
import type { RequestHandler } from "./$types";
import docs from "../docs.md?raw";
export const GET: RequestHandler = async () => {
return new Response(docs, {
headers: {
"Content-Type": "text/plain; charset=utf-8",
"Cache-Control": "public, max-age=3600",
},
});
};folderStructure: `src/
└── lib/
└── components/
└── magic/
└── your-component/
├── your-component.svelte
└── index.ts`,OR
folderStructure: `src/
lib/
├── components/
│ └── magic/
│ └── warp-background/
│ ├── warp-background.svelte
│ └── index.tsAdd your component entry to the items array in registry.json:
{
"name": "your-component",
"type": "registry:block",
"title": "Your Component",
"description": "Brief description of the component.",
"files": [
{
"path": "./src/lib/components/magic/your-component/your-component.svelte",
"type": "registry:component",
"target": "magic/your-component/your-component.svelte"
},
{
"path": "./src/lib/components/magic/your-component/index.ts",
"type": "registry:file",
"target": "magic/your-component/index.ts"
}
],
"registryDependencies": [],
"dependencies": ["motion-sv"]
}For components with custom CSS animations:
{
"name": "your-component",
"cssVars": {
"theme": {
"animate-your-animation": "your-animation 2s ease infinite"
}
},
"css": {
"@keyframes your-animation": {
"0%": { "opacity": "0" },
"100%": { "opacity": "1" }
}
}
}Run the registry build command:
pnpm registry:buildThis generates JSON files in static/r/ for each component, enabling CLI installation.
Test the component can be installed correctly:
# In a test Svelte project with shadcn-svelte installed
npx shadcn-svelte@latest add "http://localhost:5173/r/your-component.json"- Component files are copied correctly
- Dependencies are added to
package.json - CSS variables are added (if any)
- Component works as expected
-
Create a branch:
git checkout -b feat/your-component
-
Commit changes:
git add . git commit -m "feat: add your-component"
-
Push and create PR:
git push origin feat/your-component
-
PR Checklist:
- Component created in
src/lib/components/magic/ - Route created in
src/routes/magic/docs/components/ -
+page.sveltewith proper SEO -
llms.txt/+server.tsservingdocs.md -
docs.mdwith AI-readable documentation -
examples/withpreview.svelteand any variants -
data.tswith proper types, code, SEO, examples - Component added to
registry.json - Registry built successfully (
pnpm registry:build) - Component tested via installation
- Component created in
- Naming: Use kebab-case for folder/file names and component IDs
- Props: Document all props with types and defaults
- Examples: Create at least one preview and one variant example
- Dependencies: Only include necessary npm packages
- CSS: Use Tailwind classes when possible; use
cssVars/cssfor animations - Testing: Always test installation in a fresh project before PR