How rborges89/react-slots-tools works
Project type and purpose
• This is an open-source React utility library (npm package) named @burning89/react-slots-tools.
• Its purpose is to provide a hook (useSlots) and components (TemplateSlot) that let React authors define and consume named “slots” in a type-safe, composable way—similar to slot patterns in Vue or Web Components.
File structure
• Top‐level build & config files:
• tsup.config.ts – defines bundling (CJS + ESM + .d.ts)
• tsconfig.json – TypeScript compiler options
• vitest.config.ts – test runner config
• package.json / package-lock.json – dependencies, scripts (dev, build, test)
• Source directory (src/):
• useSlots.tsx – core hook implementation
• TemplateSlot.tsx – component for slots with parameters
• types.ts – type definitions (SlotWithParameters, NamedSlotsMap, UseSlotsResult)
• index.ts – public API exports
• useSlots.test.tsx – unit tests against the hook
• Distribution directory (dist/):
• Bundled outputs in multiple module formats (.mjs, .cjs) and type declarations
README for additional insights
• Core API: useSlots<T>(children) returns { slots, get, has, list }.
• Slot usage patterns: default vs named slots vs parameterized slots.
• Example consumer code shows how a React app imports and uses the library.
• Build & test commands reinforce that this is a pure-frontend library with no backend or external services.