Files
kandev/apps/web/lib/plugins/plugin-boot-bridge.tsx
João Salavisa 1a3c134f1a feat(plugins): ship the plugin system without a feature flag (#2086)
Co-authored-by: Kandev Agent <agent@kandev.dev>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-31 08:59:34 +01:00

28 lines
828 B
TypeScript

"use client";
import { useEffect } from "react";
import { useAppStoreApi } from "@/components/state-provider";
import { bootPlugins } from "./boot";
import type { ActivePlugin } from "./types";
type PluginBootBridgeProps = {
plugins?: ActivePlugin[];
};
/**
* Mounted once at the app root (inside `StateProvider`, see `src/main.tsx`).
* Triggers `bootPlugins` as soon as the store + boot payload plugins are
* available. Renders nothing — `bootPlugins` itself guards against
* double-loading a store that has already booted, so repeated effect runs
* (StrictMode double-invoke, re-renders) are safe no-ops.
*/
export function PluginBootBridge({ plugins }: PluginBootBridgeProps) {
const store = useAppStoreApi();
useEffect(() => {
bootPlugins({ plugins }, store);
}, [plugins, store]);
return null;
}