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 typesAddonAssets and AddonAsset types for private packaged filesHostAPI interface for all financial APIsKey exports:
import type {
AddonContext,
AddonEnableFunction,
AddonAsset,
AddonAssets,
HostAPI,
Permission,
RiskLevel,
} from "@wealthfolio/addon-sdk";
Version: 3.7.0 Peer Dependencies: React ^19.2.4
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-addon CLI command (wealthfolio is a deprecated alias)CLI commands:
# Create new addon
wealthfolio-addon create my-addon
# Start development server
wealthfolio-addon dev
# Build addon
wealthfolio-addon build
# Package for distribution
wealthfolio-addon package
All addons must use the host-provided React version:
{
"dependencies": {
"react": "^19.2.4",
"react-dom": "^19.2.4"
}
}
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"
}
}
TypeScript support with proper types:
{
"devDependencies": {
"typescript": "^5.8.3",
"@types/node": "^22.14.0",
"@types/react": "^19.2.13",
"@types/react-dom": "^19.2.3"
}
}
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": "^3.7.0",
"@wealthfolio/ui": "^3.7.0",
"react": "^19.2.4"
}
}
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-addon dev",
"clean": "rm -rf dist *.zip",
"package": "zip -r my-addon.zip manifest.json dist/ assets/ README.md",
"bundle": "npm run clean && npm run build && npm run package",
"lint": "tsc --noEmit"
},
"dependencies": {
"@wealthfolio/addon-sdk": "^3.7.0",
"@wealthfolio/ui": "^3.7.0",
"react": "^19.2.4",
"react-dom": "^19.2.4"
},
"devDependencies": {
"@wealthfolio/addon-dev-tools": "^3.7.0",
"@types/node": "^22.14.0",
"@types/react": "^19.2.13",
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^4.4.1",
"typescript": "^5.8.3",
"vite": "^6.2.7"
}
}
Standard vite.config.ts:
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
const hostProvidedDependencies = [
"@tanstack/react-query",
"@wealthfolio/addon-sdk",
"@wealthfolio/ui",
"date-fns",
"lucide-react",
"react",
"react-dom",
"react-dom/client",
"react/jsx-runtime",
"recharts",
];
export default defineConfig({
plugins: [react()],
define: {
"process.env.NODE_ENV": JSON.stringify("production"),
},
build: {
target: ["chrome107", "edge107", "firefox104", "safari16"],
lib: {
entry: "src/addon.tsx",
fileName: () => "addon.js",
formats: ["es"],
},
rollupOptions: {
external: hostProvidedDependencies,
},
outDir: "dist",
minify: false,
sourcemap: true,
},
});
Always use compatible versions:
| SDK Version | Wealthfolio Version | React Version |
|---|---|---|
| 3.7.x | 3.7.0+ | ^19.2.4 |
| 3.6.x | 3.6.0+ | ^19.2.4 |
Major version increments indicate breaking changes:
ctx.assets require SDK and Wealthfolio 3.7 or newer.Wealthfolio indexes files below assets/** and dist/assets/** without an
assets manifest field. Use ctx.assets.getBlob(path) for bytes and
ctx.assets.getUrl(path) for images, fonts, media, and Wasm-compatible Blob
URLs. Local CSS url(...) references are rewritten automatically.
ctx.assets is private package content; ctx.api.assets is the financial asset
domain API. See the
v3.6 to v3.7 migration guide for
limits, CSS restrictions, lifecycle, and compatibility.
Packaged assets can be consumed by images, fonts, media elements, CSS, and WebAssembly. The sandbox does not allow Worker or service-worker entry points, popups, direct network requests, or remote CSS imports.
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-addon dev
# or if installed globally
wealthfolio-addon dev
The development server automatically:
Supported file types:
.tsx, .ts - TypeScript/React components.json - Manifest and configuration files.css - Stylesheetsassets/ - Private packaged resourcesThe development server runs on port 3001 by default. The host discovers it via
/health, loads one coherent /runtime-package generation, and lazily requests
asset bytes from that same generation.
Use @wealthfolio/addon-dev-tools 3.7 or newer with Wealthfolio 3.7.
Standard development scripts setup:
{
"scripts": {
"dev:server": "wealthfolio-addon 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
š” Runtime package available at: http://localhost:3001/runtime-package
Server won't start:
# Check if ports are available
lsof -i :3001
# Kill conflicting processes
kill -9 <PID>
Hot reload not working:
Wealthfolio 3.7 requires @wealthfolio/addon-dev-tools 3.7 or newer. A 404/405
for /runtime-package means the running development server must be upgraded and
restarted. Runtime packages are immutable generation snapshots; the server
retains the four most recent generations for lazy asset requests.
# 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.2.4 react-dom@^19.2.4 # Match the host version
Missing peer dependencies:
npm install --peer-deps # Install peer dependencies
Build errors:
npm run clean && npm run build # Clean rebuild