{"library":"ngx-indexed-db","title":"Angular IndexedDB Wrapper","description":"ngx-indexed-db is an Angular service that provides a reactive, observable-based wrapper around the browser's IndexedDB API. It simplifies database interactions for Angular applications, supporting both client-side rendering (CSR) and server-side rendering (SSR) since version 19.2.0. The current stable version is 22.0.0. While the exact release cadence isn't explicitly stated, the version numbers often align with Angular's major releases, suggesting active development. Key differentiators include its observable-driven API, full SSR compatibility, and the ability to provide custom IndexedDB implementations via an injection token for enhanced testing or non-browser environments. It also features a robust migration system for evolving database schemas.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install ngx-indexed-db"],"cli":null},"imports":["import { NgxIndexedDBModule } from 'ngx-indexed-db'","import { DBConfig } from 'ngx-indexed-db'","import { provideIndexedDb } from 'ngx-indexed-db'","import { NgxIndexedDBService } from 'ngx-indexed-db'","import { SERVER_INDEXED_DB } from 'ngx-indexed-db'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { NgModule, ApplicationConfig } from '@angular/core';\nimport { NgxIndexedDBModule, provideIndexedDb, DBConfig } from 'ngx-indexed-db';\n\n// Ahead of time compiles requires an exported function for factories\nexport function migrationFactory() {\n  return {\n    1: (db, transaction) => {\n      const store = transaction.objectStore('people');\n      store.createIndex('country', 'country', { unique: false });\n    },\n    3: (db, transaction) => {\n      const store = transaction.objectStore('people');\n      store.createIndex('age', 'age', { unique: false });\n    }\n  };\n}\n\nconst dbConfig: DBConfig  = {\n  name: 'MyDb',\n  version: 3,\n  objectStoresMeta: [{\n    store: 'people',\n    storeConfig: { keyPath: 'id', autoIncrement: true },\n    storeSchema: [\n      { name: 'name', keypath: 'name', options: { unique: false } },\n      { name: 'email', keypath: 'email', options: { unique: false } }\n    ]\n  }, {\n    store: 'animals',\n    storeConfig: { keyPath: 'id', autoIncrement: true },\n    storeSchema: [\n      { name: 'name', keypath: 'name', options: { unique: true } }\n    ]\n  }],\n  migrationFactory\n};\n\n// For NgModule-based applications\n@NgModule({\n  imports: [\n    NgxIndexedDBModule.forRoot(dbConfig)\n  ]\n})\nexport class AppModule { }\n\n// For Standalone API (main.ts or component providers)\nconst appConfig: ApplicationConfig = {\n  providers: [\n    provideIndexedDb(dbConfig)\n  ]\n};","lang":"typescript","description":"This quickstart demonstrates configuring ngx-indexed-db for both NgModule and standalone Angular applications, including defining the database schema and implementing version migrations.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}