Skip to content

ZStore is a lightweight, type-safe, and migration-friendly data store for TypeScript applications, built on top of Zod for schema validation and serialization.

Notifications You must be signed in to change notification settings

adnanlah/zstore

Repository files navigation

ZStore

Simple data persistence for your Electron app or module - Save and load user settings, app state, cache, etc

Usage

import { z } from 'zod';
import ZStore from 'zstore';

// version is mandantory
// default values are also mandatory
const userSchemaV1 = z.object({
  version: z.literal(1).default(1),
  name: z.string().default(''),
  age: z.number().default(0)
});

const userStore = new ZStore({
  schema: userSchemaV1,
  allSchemas: [userSchemaV1],
  name: 'user'
});

userStore.set({
  name: 'Adnan',
  age: 25
});

console.log(userStore.store);

About

ZStore is a lightweight, type-safe, and migration-friendly data store for TypeScript applications, built on top of Zod for schema validation and serialization.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published