Josh Vaage

Software Engineer. Open Source & Projects.

← Back to Projects

storefront

storefront preview

Storefront is a lightweight, flat-file database with a Prisma-like interface designed specifically for browser environments. It provides a simple, intuitive ORM (Object-Relational Mapping) using the File System Access API to manage data persistently on the user's local disk.

Language TypeScript
Last Pushed 2/28/2026

Storefront

npm version

Storefront is a lightweight, flat-file database with a Prisma-like interface designed specifically for browser environments. It provides a simple, intuitive ORM (Object-Relational Mapping) using the File System Access API to manage data persistently on the user's local disk.

Features

  • File System Access API: Real, persistent local storage.
  • Prisma-inspired API: Familiar query patterns (findMany, create, update, delete).
  • First-class TypeScript: Type-safe queries and results.
  • Lightweight: Zero-dependency core.
  • Concurrent Safety: Built-in locking for reliable operations.

Installation

npm install storefront

Quick Start

1. Create a Schema

Create a schema.storefront file to define your data models:

user {
  name: string
  email: string
  age: number
}

post {
  title: string
  content: string
  authorId: string
}

2. Generate Types

Generate TypeScript types from your schema:

npx storefront generate

3. Initialize and Use Storefront

import { StorefrontClient } from 'storefront'

// Define your schema type (usually generated)
type Schema = {
  user: {
    id: string
    name: string
    email: string
    age: number
  }
  post: {
    id: string
    title: string
    content: string
    authorId: string
  }
}

async function init() {
  // Request directory access
  const dirHandle = await window.showDirectoryPicker()

  // Initialize the client
  const db = new StorefrontClient<Schema>(dirHandle)

  // Create a record
  const newUser = await db.model('user').create({
    name: 'Josh',
    email: 'josh@example.com',
    age: 30,
  })

  // Query with Prisma-like syntax
  const users = await db.model('user').findMany({
    where: {
      age: { gte: 18 }
    },
    orderBy: { name: 'asc' }
  })
}

Query Capabilities

Storefront supports standard ORM operations:

  • Filtering: equals, gt, gte, lt, lte, contains, startsWith, endsWith
  • Logic: AND, OR, NOT
  • Pagination: take, skip
  • Sorting: orderBy

Environment Support

Storefront requires a browser that supports the File System Access API. This is currently available in Chrome, Edge, and other Chromium-based browsers.

License

MIT