npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

valet-dev

v0.0.20

Published

[![npm version](https://img.shields.io/npm/v/valet-dev.svg)](https://www.npmjs.com/package/valet-dev) [![License](https://img.shields.io/npm/l/valet-dev.svg)](https://github.com/expo/valet/blob/main/LICENSE)

Readme

valet-dev

npm version License

Local-first, real-time sync SDK for building reactive applications with automatic offline support and replay-based conflict resolution.

Valet is a TypeScript SDK that enables building modern local-first applications with real-time sync capabilities, similar to Convex. It provides React hooks, automatic sync, offline support, and deterministic replay for conflict resolution.

Features

  • 🔄 Real-time Sync - Automatic synchronization between client and server
  • 💾 Local-First - Client maintains a local SQLite replica for instant queries
  • 🔌 Offline Support - Full functionality without network connection
  • ⚛️ React Integration - First-class React hooks (useQuery, useMutation)
  • 🔐 Authentication - Built-in auth with automatic token refresh
  • 🛡️ Type Safety - End-to-end TypeScript types with code generation
  • 🔀 Conflict Resolution - Deterministic replay for seamless multi-user collaboration

Installation

npm install valet-dev
# or
bun add valet-dev

Quick Start

1. Define Your Schema

Create a schema file (e.g., valet/schema.ts):

import { defineSchema, defineTable } from 'valet-dev/server'
import { v } from 'valet-dev/server'

export default defineSchema({
  todos: defineTable({
    title: v.string(),
    completed: v.number(),
    userId: v.string(),
  }),
})

2. Define Queries and Mutations

Create your API functions (e.g., valet/todos.ts):

import { defineQuery, defineMutation, v } from '../_generated/valet/api'

export const list = defineQuery({
  args: {
    completed: v.optional(v.number()),
  },
  execution: 'local',
  handler: async (ctx, args) => {
    let query = ctx.db.query('todos')
    if (args.completed !== undefined) {
      query = query.filter((q) => q.eq('completed', args.completed))
    }
    return query.collect()
  },
})

export const create = defineMutation({
  args: {
    title: v.string(),
  },
  handler: async (ctx, args) => {
    return ctx.db.insert('todos', {
      title: args.title,
      completed: 0,
      userId: ctx.auth?.userId ?? 'anonymous',
    })
  },
})

3. Use in Your React App

import { ValetProvider, useQuery, useMutation } from './_generated/valet/react'
import { api } from './_generated/valet/api'

function App() {
  return (
    <ValetProvider
      url="wss://your-app.valet.host/ws"
      authToken={() => getAuthToken()}
    >
      <TodoList />
    </ValetProvider>
  )
}

function TodoList() {
  const { data: todos } = useQuery(api.todos.list, { completed: 0 })
  const createTodo = useMutation(api.todos.create)

  return (
    <div>
      {todos?.map(todo => (
        <div key={todo._id}>{todo.title}</div>
      ))}
      <button onClick={() => createTodo.mutate({ title: 'New task' })}>
        Add Todo
      </button>
    </div>
  )
}

Package Exports

The package provides several entry points for different use cases:

  • valet-dev - Core client library (protocol types, message serialization)
  • valet-dev/react - React hooks and components (useQuery, useMutation, ValetProvider)
  • valet-dev/server - Server function definitions (validators, schema, query/mutation builders)
  • valet-dev/local - Local database client for browser environments
  • valet-dev/qb - Query builder for constructing filters
  • valet-dev/codegen - Code generation utilities (CLI: valet-dev codegen)

Code Generation

Valet includes a code generator that creates type-safe TypeScript definitions from your schema:

# Generate types once
npx valet-dev codegen

# Watch mode for development
npx valet-dev codegen --watch

This generates:

  • Type definitions for your schema
  • Fully-typed api object with all your queries and mutations
  • Custom ValetProvider and hooks with your schema types

API Overview

React Hooks

  • useQuery(api.namespace.query, args) - Subscribe to a query with automatic updates
  • useMutation(api.namespace.mutation) - Get a mutation function to modify data
  • useConnectionState() - Monitor connection status (connected, connecting, disconnected)
  • useValetAuth() - Access authentication state and user info
  • useValetClient() - Access the underlying client for advanced operations

Query Execution Modes

  • local - Executes in the browser against local SQLite replica (instant, offline-capable)
  • server - Executes on the server with full database access

Context API

Inside query/mutation handlers, access:

  • ctx.db - Database query and mutation operations
  • ctx.auth - Authentication info (userId, token claims)

Development

# Install dependencies
bun install

# Build the package
bun run build

# Run type checking
bun run typecheck

# Run tests
bun test

Documentation

For complete documentation, architecture details, and examples:

License

See LICENSE file.