{"id":18800820,"url":"https://github.com/bangle-io/nalanda","last_synced_at":"2025-04-13T17:31:42.644Z","repository":{"id":65733327,"uuid":"594888573","full_name":"bangle-io/nalanda","owner":"bangle-io","description":"A state management library","archived":false,"fork":false,"pushed_at":"2023-11-18T21:15:35.000Z","size":1756,"stargazers_count":4,"open_issues_count":14,"forks_count":0,"subscribers_count":2,"default_branch":"dev","last_synced_at":"2025-03-27T08:45:13.530Z","etag":null,"topics":["javascript","react","react-state-management","state","state-management","state-manager","typescript"],"latest_commit_sha":null,"homepage":"https://nalanda.bangle.io","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bangle-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2023-01-29T23:23:26.000Z","updated_at":"2023-10-23T13:30:03.000Z","dependencies_parsed_at":"2023-10-15T00:04:46.451Z","dependency_job_id":"e997d1c2-65ef-4a6c-a103-0ccb2d5a3e7f","html_url":"https://github.com/bangle-io/nalanda","commit_stats":{"total_commits":194,"total_committers":1,"mean_commits":194.0,"dds":0.0,"last_synced_commit":"7256e3c86ac9db3228823bcea939ea85f65c721b"},"previous_names":[],"tags_count":55,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bangle-io%2Fnalanda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bangle-io%2Fnalanda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bangle-io%2Fnalanda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bangle-io%2Fnalanda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bangle-io","download_url":"https://codeload.github.com/bangle-io/nalanda/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248290042,"owners_count":21078923,"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","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":["javascript","react","react-state-management","state","state-management","state-manager","typescript"],"created_at":"2024-11-07T22:20:06.965Z","updated_at":"2025-04-13T17:31:39.477Z","avatar_url":"https://github.com/bangle-io.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://nalanda.bangle.io\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/bangle-io/nalanda/dev/documentation/public/nalanda.png\"\n        alt=\"screen\" width=\"128\" \u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003ch2 align=\"center\"\u003e\n  Nalanda\n\u003c/h2\u003e\n\n\u003cp align=\"center\"\u003e\nEffortlessly Powerful State Management Simple to Start, Designed to Scale.\n\u003c/p\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://nalanda.bangle.io/docs\"\u003eRead the docs\u003c/a\u003e\n\u003c/div\u003e\n\n## Features\n\n- **Predictable State Management:** No magic, predictable state management that scales with your app.\n- **Performance Optimized:** With explicit dependency management, slices of state only update when necessary, ensuring optimal performance.\n- **TypeScript First:** Leverages TypeScript to catch errors at compile-time.\n- **Powerful Effects System:** Handle complex logic outside of your UI components.\n- **Scalability:** Allows you to break your app into small, testable, and maintainable slices.\n- **Framework Agnostic:** Works seamlessly with any framework.\n\n### Installation\n\n```sh\nnpm i @nalanda/core\n\n# for react\nnpm i @nalanda/react\n```\n\n## Quick Start\n\n### Creating a Slice\n\nLets start by creating a simple counter slice.\n\n```tsx filename=\"counter-slice.ts\"\nimport { createKey } from '@nalanda/core';\n\n// The key is a local helper used to define various components of your slice.\nconst key = createKey('counterSlice', []);\n\n// State fields define part of your state.\nconst counter = key.field(0);\n\n// Actions define how a field/s should be updated.\nfunction increment() {\n  return counter.update((c) =\u003e c + 1);\n}\n\n// A slice serves as an interface, revealing the specified fields\n// and actions to the entire application.\nexport const counterSlice = key.slice({\n  counter,\n  increment,\n});\n```\n\n### Setting up the Store\n\nAt the root of your React app, set up a store and encapsulate your app with the StoreProvider component:\n\n```tsx copy filename=\"app.tsx\"\nimport { StoreProvider } from '@nalanda/react';\nimport { createStore } from '@nalanda/core';\nimport { counterSlice } from './counter-slice';\n\n// Establish a global store incorporating your slices.\nconst store = createStore({\n  slices: [counterSlice],\n});\n\nReactDOM.render(\n  // use the StoreProvider to make the store available to the entire app.\n  \u003cStoreProvider store={store}\u003e\n    \u003cApp /\u003e\n  \u003c/StoreProvider\u003e,\n  document.getElementById('root'),\n);\n```\n\n### Displaying the counter\n\nWith the store in place, employ the useSlice hook to access the state and actions from the slice:\n\n```tsx copy filename=\"counter.tsx\"\nimport { useTrack, useStore } from '@nalanda/react';\nimport { counterSlice } from './counter-slice';\n\nexport function Counter() {\n  // useTrack re-render the component whenever `counter` changes\n  const { counter } = useTrack(counterSlice);\n  const store = useStore();\n\n  const increment = () =\u003e {\n    // Dispatch an action to update the slice\n    store.dispatch(counterSlice.increment());\n  };\n\n  return (\n    \u003cdiv\u003e\n      \u003ch1\u003eCounter\u003c/h1\u003e\n      \u003cp\u003e{counter}\u003c/p\u003e\n      \u003cbutton onClick={increment}\u003eincrement\u003c/button\u003e\n    \u003c/div\u003e\n  );\n}\n```\n\n### Next Steps\n\n- Dive deeper into Nalanda by exploring our [official documentation](https://nalanda.bangle.io).\n- View [real-world examples](https://nalanda.bangle.io/docs/examples) to see Nalanda in action.\n\n### Contribute to Nalanda\n\nYour contribution can make `nalanda` even better! If you're interested in lending a hand, please consult our [CONTRIBUTING.md](CONTRIBUTING.md) guide.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbangle-io%2Fnalanda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbangle-io%2Fnalanda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbangle-io%2Fnalanda/lists"}