{"id":45497,"library":"muya-sqlite","title":"muya-sqlite","description":"A tiny SQLite companion for muya state management library (v0.0.5). Reactive, paginated, type-safe queries over SQLite tables that auto-sync on data mutation. Uses a push-driven subscription model: views update automatically when any part of the app calls set/delete/batchSet on the underlying table. Returns TanStack-style hook result (data, status, isLoading, isFetching, isStale, isError, error, hasNextPage, fetchNextPage, refetch). Optional global cache via cacheKey persists data and subscriptions across mount/unmount cycles. Built on useSyncExternalStore, concurrent-safe, no QueryClientProvider required. Requires muya >=2.5.8 and react >=18 <20.","status":"active","version":"0.0.5","language":"javascript","source_language":"en","source_url":"https://github.com/samuelgjabel/muya","tags":["javascript","react","react-native","sqlite","state","muya","typescript"],"install":[{"cmd":"npm install muya-sqlite","lang":"bash","label":"npm"},{"cmd":"yarn add muya-sqlite","lang":"bash","label":"yarn"},{"cmd":"pnpm add muya-sqlite","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for state management primitives","package":"muya","optional":false},{"reason":"peer dependency for hooks and JSX","package":"react","optional":false}],"imports":[{"note":"ESM-only package; no default export.","wrong":"const createSqliteState = require('muya-sqlite')","symbol":"createSqliteState","correct":"import { createSqliteState } from 'muya-sqlite'"},{"note":"Main entry re-exports the hook; do not deep-import.","wrong":"import { useSqliteValue } from 'muya-sqlite/dist/esm/hooks/use-sqlite-value'","symbol":"useSqliteValue","correct":"import { useSqliteValue } from 'muya-sqlite'"},{"note":"Deep imports are not guaranteed stable between minor versions.","wrong":"import { bunMemoryBackend } from 'muya-sqlite/dist/esm/table/bun-backend'","symbol":"bunMemoryBackend","correct":"import { bunMemoryBackend } from 'muya-sqlite'"}],"quickstart":{"code":"import { createSqliteState, useSqliteValue } from 'muya-sqlite'\nimport { bunMemoryBackend } from 'muya-sqlite'\ninterface Person {\n  id: string\n  name: string\n  age: number\n}\nconst people = createSqliteState<Person>({\n  backend: bunMemoryBackend(),\n  tableName: 'people',\n  key: 'id',\n  indexes: ['age'],\n})\nawait people.batchSet([\n  { id: '1', name: 'Alice', age: 30 },\n  { id: '2', name: 'Bob', age: 25 },\n])\nfunction PeopleList() {\n  const { data, status, hasNextPage, fetchNextPage } = useSqliteValue(people, {\n    sortBy: 'age',\n    pageSize: 50,\n  })\n  if (status === 'pending') return <p>Loading&hellip;</p>\n  if (status === 'error') return <p>Failed to load</p>\n  return (\n    <>\n      <ul>\n        {data?.map((p) => (\n          <li key={p.id}>{p.name} ({p.age})</li>\n        ))}\n      </ul>\n      {hasNextPage && <button onClick={() => fetchNextPage()}>Load more</button>}\n    </>\n  )\n}","lang":"typescript","description":"Minimal runnable example: create a SQLite-backed reactive state, insert two rows, and render a paginated list that auto-updates on mutation."},"warnings":[{"fix":"Wrap the state creation in an async function or top-level await.","message":"`createSqliteState` is async – you must `await` the backend Promise if `backend` option is async.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Install react@18 or react@19.","message":"Peer dependency `react` must be >=18 <20. Using React 17 or 20+ will cause runtime errors.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Use `import { useSqliteValue } from 'muya-sqlite'` instead.","message":"Deep imports like `muya-sqlite/dist/esm/hooks/use-sqlite-value` may break in patch releases. Only import from the package root.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Always provide `key` option – the same field will be used as the document identifier.","message":"Table `key` must be a unique primary key. If the SQLite table has a different PK, you must still specify `key` matching a field in Document.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"No user action needed, but bear in mind double renders in dev.","message":"React strict mode in development will double-mount and double-subscribe, but the library handles deduplication internally.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'18':94 '2.5.8':91 '20':95 'across':77 'app':45 'auto':25 'auto-sync':24 'automat':39 'built':80 'cach':70 'cachekey':72 'call':46 'companion':7 'concurr':84 'concurrent-saf':83 'cycl':79 'data':28,58,74 'driven':34 'error':64 'fetchnextpag':66 'global':69 'hasnextpag':65 'hook':56 'iserror':63 'isfetch':61 'isload':60 'isstal':62 'javascript':96 'librari':12 'manag':11 'model':36 'mount/unmount':78 'mutat':29 'muya':2,9,90,103 'muya-sqlit':1 'nativ':100 'option':68 'pagin':15 'part':42 'persist':73 'push':33 'push-driven':32 'queri':19 'queryclientprovid':87 'react':93,97,99 'react-nat':98 'reactiv':14 'refetch':67 'requir':88,89 'result':57 'return':52 'safe':18,85 'set/delete/batchset':47 'sqlite':3,6,21,101 'state':10,102 'status':59 'style':55 'subscript':35,76 'sync':26 'tabl':22,51 'tanstack':54 'tanstack-styl':53 'tini':5 'type':17 'type-saf':16 'typescript':104 'under':50 'updat':38 'use':30 'usesyncexternalstor':82 'v0.0.5':13 'via':71 'view':37","created_at":"2026-06-07T12:55:18.249399+00:00","updated_at":"2026-06-07T12:55:18.249399+00:00","problems":[{"fix":"Run `npm install muya muya-sqlite` or `bun add muya muya-sqlite`.","cause":"Package not installed or missing peer dependency muya.","error":"Error: Cannot find module 'muya-sqlite'"},{"fix":"Use `import { createSqliteState } from 'muya-sqlite'`.","cause":"Wrong import syntax – attempting to use the result of a default import or require().","error":"TypeError: createSqliteState is not a function"},{"fix":"Install react@18 or react@19: `npm install react@18`.","cause":"React not installed or wrong version (<18).","error":"Error: React is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/samuelgjabel/muya","github":"https://github.com/samuelgjabel/muya","docs":null,"changelog":null,"pypi":null,"npm":"muya-sqlite","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}