{"id":31717884,"url":"https://github.com/zobla-kv/react-di-lite","last_synced_at":"2025-10-09T02:08:01.786Z","repository":{"id":317995458,"uuid":"1069629549","full_name":"zobla-kv/react-di-lite","owner":"zobla-kv","description":"Lightweight, hierarchical dependency injection for React inspired by Angular’s services.","archived":false,"fork":false,"pushed_at":"2025-10-06T11:08:11.000Z","size":63864,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-06T12:23:25.373Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/react-di-lite","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zobla-kv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-04T10:06:04.000Z","updated_at":"2025-10-06T11:48:09.000Z","dependencies_parsed_at":"2025-10-06T12:24:11.101Z","dependency_job_id":null,"html_url":"https://github.com/zobla-kv/react-di-lite","commit_stats":null,"previous_names":["zobla-kv/react-di","zobla-kv/react-di-lite"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/zobla-kv/react-di-lite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zobla-kv%2Freact-di-lite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zobla-kv%2Freact-di-lite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zobla-kv%2Freact-di-lite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zobla-kv%2Freact-di-lite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zobla-kv","download_url":"https://codeload.github.com/zobla-kv/react-di-lite/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zobla-kv%2Freact-di-lite/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000774,"owners_count":26082906,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-09T02:01:35.711Z","updated_at":"2025-10-09T02:08:01.780Z","avatar_url":"https://github.com/zobla-kv.png","language":"TypeScript","funding_links":[],"categories":["Angular-Inspired Solutions"],"sub_categories":["Wrappers"],"readme":"# react-di-lite\n\n\u003e **Lightweight, hierarchical dependency injection for React — inspired by Angular’s services.**\n\n---\n\n## 📖 Description\n\nReact Service Provider offers a simple and powerful way to manage shared state and logic across your React application.\n\nIt brings Angular-like service patterns into React — enabling **hierarchical dependency injection** and **shared instances** across your component tree.\n\n---\n\n## ⚙️ Prerequisites\n\n- **React**: `^17.0.0` or higher\n- **TypeScript** (recommended): for full IntelliSense and type safety\n\n---\n\n## 📦 Installation\n\n```bash\nnpm install react-di-lite\n# or\nyarn add react-di-lite\n```\n\n---\n\n## 🧩 How It Works\n\nThink of it like a **React hook**, but with **shared state** — allowing multiple components to access and modify the same service instance.\n\n1. Global services provider\n\n```tsx\n// src/services/CounterService.tsx\nimport { useState } from 'react';\n\nexport const CounterService = () =\u003e {\n  const [count, setCount] = useState(0);\n  const increment = () =\u003e setCount((c) =\u003e c + 1);\n\n  return { count, increment };\n};\n\n// src/services/index.ts\nimport { createServicesProvider } from 'react-di-lite';\nimport { CounterService } from './CounterService';\n\n// name these whatever suits you\nexport const [GlobalServicesProvider, useGlobalServices] =\n  createServicesProvider({\n    counterService: CounterService,\n  });\n\n// src/App.tsx\nimport { GlobalServicesProvider } from './services';\nimport { Component1 } from './components/Component1';\nimport { Component2 } from './components/Component2';\n\nfunction App() {\n  return (\n    \u003cGlobalServicesProvider\u003e\n      \u003cComponent1 /\u003e\n      \u003cComponent2 /\u003e\n    \u003c/GlobalServicesProvider\u003e\n  );\n}\n\n// src/components/Component1.tsx\nimport { useGlobalServices } from '../services';\nexport const Component1 = () =\u003e {\n  const { counterService } = useGlobalServices();\n};\n\n// src/components/Component2.tsx\nimport { useGlobalServices } from '../services';\nexport const Component2 = () =\u003e {\n  const { counterService } = useGlobalServices();\n};\n```\n\n##### 🎥 Demo Video\n\nNotice shared state\n\n![Demo of global services provider](https://github.com/zobla-kv/react-di-lite/blob/master/assets/demo-global.gif?raw=true)\n\n2. Multiple services providers\n\n```tsx\n// src/services/index.ts\nimport { createServicesProvider } from 'react-di-lite';\nimport { CounterService } from './CounterService';\n\n// name these whatever suits you\nexport const [GlobalServicesProvider, useGlobalServices] =\n  createServicesProvider({\n    counterService: CounterService,\n    ...\n  });\nexport const [ChatServicesProvider, useChatServices] = createServicesProvider({\n  counterService: CounterService,\n  ...\n});\n\n// src/App.tsx\nimport { GlobalServicesProvider, ChatServicesProvider } from './services';\nimport { Component1 } from './components/Component1';\nimport { Component2 } from './components/Component2';\n\nfunction App() {\n  return (\n    \u003cGlobalServicesProvider\u003e\n      \u003cComponent1 /\u003e\n      \u003cChatServicesProvider\u003e\n        \u003cComponent2 /\u003e\n      \u003c/ChatServicesProvider\u003e\n    \u003c/GlobalServicesProvider\u003e\n  );\n}\n\n// src/components/Component1.tsx\nimport { useGlobalServices } from '../services';\nexport const Component1 = () =\u003e {\n  const { counterService } = useGlobalServices();\n};\n\n// src/components/Component2.tsx\nimport { useChatServices } from '../services';\nexport const Component2 = () =\u003e {\n  const { counterService } = useChatServices();\n};\n```\n\n##### 🎥 Demo Video\n\nNotice separate state\n\n![Demo of multiple services providers](https://github.com/zobla-kv/react-di-lite/blob/master/assets/demo-multiple.gif?raw=true)\n\n---\n\n## 💪 Fully Typed\n\nBuilt entirely with **TypeScript**, the library provides:\n\n- Full **IntelliSense** support in your IDE\n- Automatic type inference for injected services\n\n![Demo of typescript](https://github.com/zobla-kv/react-di-lite/blob/master/assets/demo-typescript.gif?raw=true)\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzobla-kv%2Freact-di-lite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzobla-kv%2Freact-di-lite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzobla-kv%2Freact-di-lite/lists"}