zen Svelte Themes

Zen

⚑ Hyper-optimized state management library - 1.7-45x faster than competitors with 1.45 kB gzipped bundle

Zen - Reactive State Management 🧘

The tiniest, fastest reactive state library with auto-tracking magic

2.49 KB β€’ 2.97x vs Solid β€’ Auto-tracking β€’ Zero config

Core Package β€’ Framework Integrations β€’ Utilities β€’ Quick Start


πŸš€ Overview

Zen is a revolutionary reactive state management library that combines extreme minimalism with magical auto-tracking. Built for modern applications, Zen provides the smallest bundle size without sacrificing performance or developer experience.

The Problem:

Traditional state libraries:
- Large bundle sizes ❌
- Manual dependency tracking ❌
- Verbose APIs ❌
- Poor performance ❌

The Solution:

Zen:
- 2.49 KB gzipped βœ…
- Automatic dependency tracking βœ…
- Clean, unified API βœ…
- Blazing fast performance βœ…

Result: Minimal footprint, maximum performance, zero configuration.


⚑ Key Features

Performance & Size

Feature Description Benefit
Ultra-tiny Only 2.49 KB gzipped (v3.8) Minimal bundle impact
Lightning fast 2.97x slower vs Solid.js Competitive performance
Zero overhead Auto-tracking with minimal runtime cost Optimal performance

Developer Experience

  • πŸͺ„ Auto-tracking - Dependencies tracked automatically, no manual lists
  • 🎯 Clean API - Unified .value everywhere, no get()/set()
  • πŸ“¦ Framework agnostic - Use with React, Vue, Svelte, Solid, or vanilla JS
  • πŸ”Œ Extensible - Modular utilities for persistence, routing, and more
  • πŸ’ͺ TypeScript-first - Full type safety out of the box

πŸ“¦ Packages

🎯 Core Package

@sylphx/zen

  • Core reactive state library
  • Auto-tracking computed values
  • Minimal API surface
  • Framework-agnostic
npm install @sylphx/zen

🎨 Framework Integrations

@sylphx/zen-react

  • React hooks integration
  • Automatic re-renders
  • Concurrent mode compatible

@sylphx/zen-vue

  • Vue 3 composition API
  • Seamless integration

@sylphx/zen-svelte

  • Svelte stores compatibility
  • Reactive bindings

@sylphx/zen-preact

  • Preact signals integration
  • Lightweight alternative to React

@sylphx/zen-solid

  • SolidJS primitives
  • Fine-grained reactivity
# Install framework integration
npm install @sylphx/zen-react
# or
npm install @sylphx/zen-vue
# or
npm install @sylphx/zen-svelte

πŸ› οΈ Utilities

@sylphx/zen-patterns - NEW v2.0 πŸŽ‰

  • Useful patterns built on zen core APIs
  • Store pattern (Zustand-style)
  • Async state management
  • Map pattern (key-level reactivity)
  • DeepMap pattern (path-level reactivity)
  • Only 936 B gzipped

@sylphx/zen-craft

  • Immutable state updates
  • 1.4-35x faster than immer
  • Type-safe mutations

@sylphx/zen-persistent

  • LocalStorage/SessionStorage persistence
  • Automatic synchronization
  • Debounced writes

@sylphx/zen-router & @sylphx/zen-router-react & @sylphx/zen-router-preact

  • Type-safe routing
  • Nested routes support
  • Framework-specific bindings
# Install utilities
npm install @sylphx/zen-patterns  # NEW! Useful patterns
npm install @sylphx/zen-craft
npm install @sylphx/zen-persistent
npm install @sylphx/zen-router-react

πŸš€ Quick Start

Basic Usage

import { zen, computed } from '@sylphx/zen';

// Create reactive state
const count = zen(0);

// Auto-tracked computed value (no manual dependencies!)
const double = computed(() => count.value * 2);

// Update state
count.value++;
console.log(double.value); // 2

With React

import { useZen } from '@sylphx/zen-react';
import { zen } from '@sylphx/zen';

const counter = zen(0);

function Counter() {
  const count = useZen(counter);

  return (
    <div>
      <p>Count: {count}</p>
      <button onClick={() => counter.value++}>Increment</button>
    </div>
  );
}

With Patterns

import { store, computedAsync, map } from '@sylphx/zen-patterns';

// Zustand-style store pattern
const counter = store(() => {
  const count = zen(0);
  return {
    count,
    increase: () => count.value++,
    decrease: () => count.value--
  };
});

// Async state management
const user = computedAsync(async () => {
  const res = await fetch('/api/user');
  return res.json();
});

// Key-level reactivity for objects
const form = map({
  name: '',
  email: '',
  age: 0
});

With Persistence

import { persistent } from '@sylphx/zen-persistent';

// Automatically synced with localStorage
const settings = persistent('user-settings', {
  theme: 'dark',
  language: 'en'
});

// Changes are automatically persisted
settings.value.theme = 'light';

πŸ“Š Comparison

Bundle Size

Library Size (gzipped) Difference
Zustand 1.2 KB Baseline
Zen v3.8 2.49 KB +108%
Jotai 3.0 KB +150%
Valtio 5.5 KB +358%
Redux Toolkit 12+ KB +900%

Performance (vs Solid.js)

Library Performance Auto-tracking Computed
Solid.js 1x (baseline) βœ… Yes βœ… Yes
Zen v3.8 2.97x slower βœ… Yes βœ… Yes
Zustand Manual tracking ❌ No ❌ No
Valtio Auto (Proxy) βœ… Proxy ❌ No
Redux Manual tracking ❌ No ❌ No

πŸ—οΈ Monorepo Structure

zen/
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ zen/                  # Core library
β”‚   β”œβ”€β”€ zen-react/            # React integration
β”‚   β”œβ”€β”€ zen-vue/              # Vue integration
β”‚   β”œβ”€β”€ zen-svelte/           # Svelte integration
β”‚   β”œβ”€β”€ zen-preact/           # Preact integration
β”‚   β”œβ”€β”€ zen-solid/            # SolidJS integration
β”‚   β”œβ”€β”€ zen-craft/            # Immutable utilities
β”‚   β”œβ”€β”€ zen-persistent/       # Persistence utilities
β”‚   β”œβ”€β”€ zen-router/           # Core routing
β”‚   β”œβ”€β”€ zen-router-react/     # React router
β”‚   └── zen-router-preact/    # Preact router
β”œβ”€β”€ docs/                     # Documentation site
β”œβ”€β”€ package.json
└── README.md

πŸ’» Development

Setup

# Install dependencies
pnpm install

# Build all packages
pnpm build

# Run tests
pnpm test

# Watch mode
pnpm test:watch

# Type checking
pnpm typecheck

# Linting
pnpm lint
pnpm lint:fix

Workspace Commands

# Build specific package
pnpm --filter @sylphx/zen build

# Test specific package
pnpm --filter @sylphx/zen test

# Dev mode for all packages
pnpm dev

πŸ“š Documentation

Core Concepts

  • State - Reactive values that trigger updates
  • Computed - Auto-tracked derived values
  • Effects - Side effects that run on changes
  • Persistence - Automatic storage synchronization

Framework Integration

Each framework package provides idiomatic bindings:

  • React: useZen() hook
  • Vue: Composition API compatible
  • Svelte: Store-compatible
  • Solid: Signal-compatible

See individual package READMEs for detailed documentation.


🎯 Use Cases

Application State

import { state, computed } from '@sylphx/zen';

const user = state({ name: 'Alice', age: 30 });
const isAdult = computed(() => user.value.age >= 18);

Form Management

const form = state({
  email: '',
  password: ''
});

const isValid = computed(() =>
  form.value.email.includes('@') &&
  form.value.password.length >= 8
);

UI State

const theme = persistent('theme', 'dark');
const sidebar = state({ open: false });
const modal = state({ show: false, content: null });

πŸ› οΈ Technology Stack

Component Technology
Language TypeScript 5.9
Package Manager pnpm
Monorepo pnpm workspaces + Turbo
Testing Vitest
Bundling tsup
Linting Biome
Documentation VitePress

πŸ—ΊοΈ Roadmap

βœ… Completed

  • Core reactive state library
  • Auto-tracking computed values
  • React integration
  • Vue integration
  • Svelte integration
  • Preact integration
  • SolidJS integration
  • Immutable utilities (zen-craft)
  • Persistence utilities
  • Routing (zen-router)

πŸš€ Planned

  • DevTools integration
  • Time-travel debugging
  • Performance profiler
  • React Native support
  • SSR optimizations
  • More utility packages

🀝 Contributing

Contributions are welcome! Please follow these guidelines:

  1. Open an issue - Discuss changes before implementing
  2. Fork the repository
  3. Create a feature branch - git checkout -b feature/my-feature
  4. Follow code standards - Run pnpm lint
  5. Write tests - Maintain high coverage
  6. Submit a pull request

Development Workflow

# 1. Install dependencies
pnpm install

# 2. Make changes to packages

# 3. Build and test
pnpm build
pnpm test

# 4. Lint and format
pnpm lint:fix
pnpm format

# 5. Create changeset
pnpm changeset

# 6. Commit and push
git commit -m "feat: add new feature"
git push

πŸ“„ License

MIT Β© Sylphx


πŸ™ Credits

Built with:


The tiniest, fastest reactive state library
2.49 KB β€’ 2.97x vs Solid β€’ Auto-tracking magic

sylphx.com β€’ @SylphxAI β€’ [email protected]

Top categories

Loading Svelte Themes