idb-ts Logo idb-ts
NEW v3.15.0 just released with lots of new features & performance improvements

Declarative, Type-Safe ORM for IndexedDB

Define your data models with TypeScript decorators. Schema creation, validation, and transactions handled automatically - no external dependencies.

$ npm install idb-ts

Engineered for Reliability

code_blocks

Declarative Entities

Define your database schema using standard TypeScript decorators. No more complex migrations or JSON-based configurations.

query_stats

Typed Query

Full autocomplete for keys and relationships.

encrypted

Validation

Built-in field constraints and types.

history

Auto Timestamps

Automatic createdAt/updatedAt management.

account_tree

Transaction API

Ensure ACID compliance in your browser storage with robust transaction handling.

save

Data Retention

Persist state across sessions reliably.

Get up and running in minutes

Define your model, build the connection, and start querying. It's that simple. No more wrestling with IndexedDB's low-level EventTarget API.

  • check_circle Automatic Store Creation
  • check_circle Built-in Primary Key Generation
  • check_circle Intelligent Query Caching
UserEntity.ts
import { Entity, PrimaryKey, Property } from 'idb-ts';

@Entity('users')
export class User {
  @PrimaryKey({ autoIncrement: true })
  id: number;

  @Property({ unique: true })
  email: string;

  @Property()
  username: string;
}

// Usage
const db = await IDB.build({ 
  entities: [User] 
});

Ready to simplify your storage?

Start building type-safe browser applications today with the most lightweight ORM in the ecosystem.