{"id":35387874,"url":"https://github.com/rodrigoslayertech/dataruni","last_synced_at":"2026-04-03T19:05:18.762Z","repository":{"id":326098280,"uuid":"1103944866","full_name":"rodrigoslayertech/dataruni","owner":"rodrigoslayertech","description":"Dataruni is a lightweight, unified database system designed for React applications.","archived":false,"fork":false,"pushed_at":"2026-01-21T03:48:04.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-07T22:39:05.308Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/rodrigoslayertech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"ROADMAP.md","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-11-25T14:43:25.000Z","updated_at":"2026-01-21T03:48:08.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/rodrigoslayertech/dataruni","commit_stats":null,"previous_names":["rodrigoslayertech/dataruni"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rodrigoslayertech/dataruni","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrigoslayertech%2Fdataruni","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrigoslayertech%2Fdataruni/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrigoslayertech%2Fdataruni/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrigoslayertech%2Fdataruni/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rodrigoslayertech","download_url":"https://codeload.github.com/rodrigoslayertech/dataruni/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrigoslayertech%2Fdataruni/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31371817,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T17:53:18.093Z","status":"ssl_error","status_checked_at":"2026-04-03T17:53:17.617Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2026-01-02T07:58:28.618Z","updated_at":"2026-04-03T19:05:18.748Z","avatar_url":"https://github.com/rodrigoslayertech.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dataruni\n\n**Dataruni** is a lightweight, unified database system designed for React applications. It bridges the gap between persistent local storage (IndexedDB) and React state, providing a seamless \"sync-to-state\" experience for offline-first applications.\n\nBuilt originally for the Codecious ecosystem, Dataruni abstracts away the complexity of IndexedDB, offering a simple hook-based API that feels just like `useState`, but with the power of a robust database backing it up.\n\n## Features\n\n- 🚀 **React-First API**: Use `useDataruniValue` just like `useState`.\n- 💾 **IndexedDB Powered**: Handles large datasets asynchronously without blocking the UI.\n- 🔄 **State Synchronization**: Automatically loads data on mount and persists updates in the background.\n- 📦 **Zero-Config**: Works out of the box with sensible defaults, but fully configurable.\n- 🔒 **Type-Safe**: Built with TypeScript for full type inference.\n- 📱 **Offline Ready**: Perfect for PWAs and mobile-first web apps.\n\n## Installation\n\n```bash\nnpm install @codecious/dataruni\n# or\npnpm add @codecious/dataruni\n# or\nyarn add @codecious/dataruni\n```\n\n## Usage\n\n### Basic Usage\n\nThe core of Dataruni is the `useDataruniValue` hook. It binds a database key to a React state variable.\n\n```tsx\nimport { useDataruniValue } from '@codecious/dataruni';\n\n// Define your configuration once\nconst dbConfig = {\n  dbName: 'MyAppDB',\n  dbVersion: 1,\n  storeName: 'my-store' // Optional, defaults to 'dataruni-store'\n};\n\nfunction AppSettings() {\n  // usage is identical to useState, but with a key and config\n  const [theme, setTheme, isLoading] = useDataruniValue\u003cstring\u003e(\n    'app-theme', // Key in the database\n    'light',     // Default value\n    dbConfig     // Database configuration\n  );\n\n  if (isLoading) {\n    return \u003cdiv\u003eLoading preferences...\u003c/div\u003e;\n  }\n\n  return (\n    \u003cbutton onClick={() =\u003e setTheme(theme === 'light' ? 'dark' : 'light')}\u003e\n      Current theme: {theme}\n    \u003c/button\u003e\n  );\n}\n```\n\n### Advanced Configuration\n\nYou can manage complex objects and arrays easily. Dataruni handles the serialization and storage for you.\n\n```tsx\ninterface UserProfile {\n  id: string;\n  name: string;\n  preferences: {\n    notifications: boolean;\n  };\n}\n\nconst [user, setUser] = useDataruniValue\u003cUserProfile | null\u003e(\n  'user-profile',\n  null,\n  dbConfig\n);\n\n// Updates are persisted automatically\nconst updateName = (newName: string) =\u003e {\n  setUser(prev =\u003e prev ? { ...prev, name: newName } : null);\n};\n```\n\n## API Reference\n\n### `useDataruniValue\u003cT\u003e(key, defaultValue, config)`\n\nThe main hook for data persistence.\n\n- **Parameters**:\n  - `key` (string): The unique identifier for the data in the store.\n  - `defaultValue` (T): The value to use if no data is found in the DB or while loading.\n  - `config` (DataruniConfig): Configuration object for the database connection.\n\n- **Returns**: `[value, setValue, isLoading]`\n  - `value` (T): The current state.\n  - `setValue` (function): Function to update state and persist to DB. Accepts a value or a callback `(prev) =\u003e newValue`.\n  - `isLoading` (boolean): True while the initial value is being fetched from IndexedDB.\n\n### `initDB(config)`\n\nInitializes the IndexedDB connection. Useful for pre-loading or side-effects outside of React components.\n\n- **Parameters**:\n  - `config` (DataruniConfig): `{ dbName: string, dbVersion?: number, storeName?: string }`\n\n- **Returns**: `Promise\u003cIDBDatabase\u003e`\n\n## License\n\nMIT © [Codecious](https://github.com/rodrigoslayertech)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodrigoslayertech%2Fdataruni","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frodrigoslayertech%2Fdataruni","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodrigoslayertech%2Fdataruni/lists"}