docs/addons/addon-packages.md
A comprehensive guide to the packages available for developing Wealthfolio addons.
The main SDK for addon development that provides TypeScript types and APIs.
npm install @wealthfolio/addon-sdk
What it provides:
AddonContext interface and typesHostAPI interface for all financial APIsKey exports:
import type {
AddonContext,
AddonEnableFunction,
HostAPI,
Permission,
RiskLevel,
} from "@wealthfolio/addon-sdk";
Version: 1.0.0 Peer Dependencies: React ^18.0.0
UI component library based on shadcn/ui and Tailwind CSS.
npm install @wealthfolio/ui
What it provides:
Key components:
import {
Button,
Card,
Dialog,
Input,
Table,
Badge,
Progress,
Tabs,
} from "@wealthfolio/ui";
Included libraries:
Development CLI and hot-reload server for addon development.
npm install -D @wealthfolio/addon-dev-tools
What it provides:
wealthfolio CLI commandCLI commands:
# Create new addon
wealthfolio create my-addon
# Start development server
wealthfolio dev
# Build addon
wealthfolio build
# Package for distribution
wealthfolio package
All addons must use React 18:
{
"dependencies": {
"react": "^19.1.1",
"react-dom": "^19.1.1"
}
}
Note: React and ReactDOM are externalized during build and provided by the host application.
Standard Vite-based build setup:
{
"devDependencies": {
"@vitejs/plugin-react": "^4.4.1",
"vite": "^6.2.7",
"rollup-plugin-external-globals": "^0.13.0"
}
}
TypeScript support with proper types:
{
"devDependencies": {
"typescript": "^5.8.3",
"@types/node": "^22.14.0",
"@types/react": "^19.1.11",
"@types/react-dom": "^18.3.0"
}
}
All Radix UI components are available through @wealthfolio/ui:
// Dialog components
import { Dialog, DialogContent, DialogTrigger } from "@wealthfolio/ui";
// Form components
import { Input, Label, Checkbox, Select } from "@wealthfolio/ui";
// Navigation
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@wealthfolio/ui";
// Feedback
import { Alert, AlertDescription, Toast } from "@wealthfolio/ui";
Lucide React icons are included:
import { TrendingUp, DollarSign, PieChart, Settings } from 'lucide-react';
export default function MyAddon() {
return (
<div>
<TrendingUp className="h-4 w-4" />
<span>Portfolio Growth</span>
</div>
);
}
Recharts for charts and graphs:
import { LineChart, Line, XAxis, YAxis, CartesianGrid } from 'recharts';
export default function PerformanceChart({ data }) {
return (
<LineChart width={400} height={300} data={data}>
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey="date" />
<YAxis />
<Line type="monotone" dataKey="value" stroke="#8884d8" />
</LineChart>
);
}
Available through @wealthfolio/ui:
import { useQuery } from '@tanstack/react-query';
export default function enable(ctx: AddonContext) {
const AccountsDisplay = () => {
const { data: accounts } = useQuery({
queryKey: ['accounts'],
queryFn: () => ctx.api.accounts.getAll()
});
return <div></div>;
};
// Register component...
}
All Tailwind classes are available:
export default function MyComponent() {
return (
<div className="flex flex-col space-y-4 p-6 bg-white rounded-lg shadow-md">
<h2 className="text-xl font-semibold text-gray-900">
Portfolio Summary
</h2>
<div className="grid grid-cols-2 gap-4">
<div className="bg-green-50 p-4 rounded">
<span className="text-green-600 font-medium">Total Value</span>
</div>
</div>
</div>
);
}
Utility classes from included packages:
import { cn } from '@wealthfolio/ui'; // clsx + tailwind-merge
export default function Card({ className, children }) {
return (
<div className={cn("rounded-lg border bg-card p-6", className)}>
{children}
</div>
);
}
Available through @wealthfolio/ui:
import { format, parseISO, isAfter } from 'date-fns';
export default function ActivityList({ activities }) {
return (
<div>
{activities.map(activity => (
<div key={activity.id}>
<span>{format(parseISO(activity.date), 'MMM dd, yyyy')}</span>
<span>{activity.type}</span>
</div>
))}
</div>
);
}
You can add other npm packages to your addon:
{
"dependencies": {
"@wealthfolio/addon-sdk": "1.0.0",
"@wealthfolio/ui": "1.0.0",
"react": "^19.1.1"
}
}
Important: External dependencies are bundled with your addon, increasing size.
Template for addon package.json:
{
"name": "my-addon",
"version": "1.0.0",
"description": "My Wealthfolio addon",
"type": "module",
"main": "dist/addon.js",
"keywords": ["wealthfolio", "addon"],
"license": "MIT",
"scripts": {
"build": "vite build",
"dev": "vite build --watch",
"dev:server": "wealthfolio dev",
"clean": "rm -rf dist *.zip",
"package": "zip -r my-addon.zip manifest.json dist/ README.md",
"bundle": "npm run clean && npm run build && npm run package",
"lint": "tsc --noEmit"
},
"dependencies": {
"@wealthfolio/addon-sdk": "1.0.0",
"@wealthfolio/ui": "1.0.0",
"react": "^19.1.1",
"react-dom": "^19.1.1"
},
"devDependencies": {
"@wealthfolio/addon-dev-tools": "^1.0.0",
"@types/node": "^22.14.0",
"@types/react": "^19.1.11",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.4.1",
"rollup-plugin-external-globals": "^0.13.0",
"typescript": "^5.8.3",
"vite": "^6.2.7"
}
}
Standard vite.config.ts:
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import externalGlobals from "rollup-plugin-external-globals";
export default defineConfig({
plugins: [react()],
define: {
"process.env.NODE_ENV": JSON.stringify("production"),
},
build: {
lib: {
entry: "src/addon.tsx",
fileName: () => "addon.js",
formats: ["es"],
},
rollupOptions: {
external: ["react", "react-dom"],
plugins: [
externalGlobals({
react: "React",
"react-dom": "ReactDOM",
}),
],
},
outDir: "dist",
minify: false,
sourcemap: true,
},
});
Always use compatible versions:
| SDK Version | Wealthfolio Version | React Version |
|---|---|---|
| 1.0.0 | 1.0.0+ | ^19.1.1 |
Major version increments indicate breaking changes:
Create a new addon with all packages:
# Using CLI (recommended)
npx @wealthfolio/addon-dev-tools create my-addon
# Manual setup
mkdir my-addon && cd my-addon
npm init -y
npm install @wealthfolio/addon-sdk @wealthfolio/ui react react-dom
npm install -D @wealthfolio/addon-dev-tools @vitejs/plugin-react vite typescript
For monorepo development:
{
"dependencies": {
"@wealthfolio/addon-sdk": "workspace:*",
"@wealthfolio/ui": "workspace:*",
"@wealthfolio/addon-dev-tools": "workspace:*"
}
}
The addon development tools provide a built-in development server with hot reload capabilities for seamless addon development.
Using npm scripts (recommended):
npm run dev:server
Using CLI directly:
npx wealthfolio dev
# or if installed globally
wealthfolio dev
The development server automatically:
Supported file types:
.tsx, .ts - TypeScript/React components.json - Manifest and configuration files.css - StylesheetsThe development server runs on ports 3001-3003 by default:
// Auto-discovery process
const DEVELOPMENT_PORTS = [3001, 3002, 3003];
// Server will bind to first available port
// Wealthfolio automatically discovers addons on these ports
Standard development scripts setup:
{
"scripts": {
"dev:server": "wealthfolio dev",
"build": "vite build",
"clean": "rm -rf dist",
"bundle": "npm run build && wealthfolio package",
"lint": "tsc --noEmit"
}
}
Instant Feedback:
Error Handling:
Development Utilities:
// Available in browser console during development
__ADDON_DEV__.getStatus(); // Check development mode status
__ADDON_DEV__.reloadAddons(); // Manual addon reload
__ADDON_DEV__.discoverAddons(); // Force addon discovery
Start development server:
npm run dev:server
Open Wealthfolio - addons are auto-discovered
Make changes to your addon code
See changes instantly in Wealthfolio
Check terminal for build status and errors
The development server provides detailed logging:
š Addon development server starting...
š Watching: /path/to/addon/src
š§ Building addon...
ā
Build successful
š Server running on http://localhost:3001
š” Addon available at: http://localhost:3001/addon.js
Server won't start:
# Check if ports are available
lsof -i :3001
lsof -i :3002
lsof -i :3003
# Kill conflicting processes
kill -9 <PID>
Hot reload not working:
# Check Wealthfolio console for discovery logs
# Verify addon manifest is valid
cat manifest.json | jq .
# Manual reload
discoverAddons() # In browser console
Build errors:
# Check TypeScript errors
npm run lint
# Clean rebuild
npm run clean && npm run build
| Feature | Development | Production |
|---|---|---|
| Source Maps | ā Enabled | ā Disabled |
| Minification | ā Disabled | ā Enabled |
| Hot Reload | ā Active | ā N/A |
| File Watching | ā Active | ā N/A |
| Dev Server | ā Required | ā N/A |
| Bundle Size | Larger | Optimized |
Multiple Addons:
# Terminal 1
cd addon-1 && npm run dev:server
# Terminal 2
cd addon-2 && npm run dev:server
# Terminal 3
cd addon-3 && npm run dev:server
Custom Port Configuration:
// vite.config.ts
export default defineConfig({
server: {
port: 3001, // Specify exact port
},
// ... rest of config
});
Environment Variables:
# .env.development
VITE_DEBUG=true
VITE_API_BASE_URL=http://localhost:8080
// Access in addon code
const debug = import.meta.env.VITE_DEBUG;
Version conflicts:
npm ls react # Check React version
npm install react@^19.1.1 # Fix version
Missing peer dependencies:
npm install --peer-deps # Install peer dependencies
Build errors:
npm run clean && npm run build # Clean rebuild