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

@vaultsync/next

v0.1.0

Published

> **VaultSync** — Next.js integration for VaultSync. Build seamless server-rendered and hydrated local-first applications.

Readme

@vaultsync/next

VaultSync — Next.js integration for VaultSync. Build seamless server-rendered and hydrated local-first applications.

npm version License: Apache 2.0

@vaultsync/next provides Next.js integration helpers, supporting both server-side rendering (SSR) data hydration on the client and hosting sync Route Handlers on the server.


Features

  • 🌊 Hydration Support — Hydrate client-side state seamlessly using initial data queried on the server.
  • ⚡ Server-Side Queries — Query local SQLite databases directly in React Server Components (RSC) or Server Actions via @vaultsync/node.
  • 📡 API Route Handler — Quickly turn any Next.js Route Handler into a VaultSync Sync Coordinator.

Installation

npm install @vaultsync/web @vaultsync/react @vaultsync/next

Quick Start

1. Server-Side Data Fetching (App Router)

Fetch data on the server and pass it to the hydration provider so client-side components render immediately without loading indicators.

// app/todos/page.tsx (React Server Component)
import { queryServerDatabase } from '@vaultsync/next/server';
import ClientTodosPage from './ClientTodosPage';

export default async function Page() {
  // Query server-side database directly
  const initialTodos = await queryServerDatabase(
    './data/vaultsync.db',
    'workspace:production',
    'todos'
  );

  const initialData = {
    todos: initialTodos,
  };

  const config = {
    namespace: 'workspace:production',
    replicaId: 'client-device-id', // Retrieve from cookie or session in real app
    coordinatorUrl: 'https://api.example.com/sync',
  };

  return (
    <ClientTodosPage config={config} initialData={initialData} />
  );
}

2. Client Hydration & Live Sync

Use the VaultSyncHydrationProvider and useNextQuery hook to display pre-fetched server data instantly, and then seamlessly switch to live local-first subscriptions once the client-side database loads.

// app/todos/ClientTodosPage.tsx (Client Component)
'use client';

import { VaultSyncHydrationProvider, useNextQuery } from '@vaultsync/next';

export default function ClientTodosPage({ config, initialData }) {
  return (
    <VaultSyncHydrationProvider config={config} initialData={initialData}>
      <TodoList />
    </VaultSyncHydrationProvider>
  );
}

function TodoList() {
  // Renders initialData.todos immediately, then subscribes to updates on client database load
  const { data: todos, loading } = useNextQuery('todos');

  return (
    <div>
      {loading && <div>Synchronizing database...</div>}
      <ul>
        {todos.map((todo: any) => (
          <li key={todo.id}>{todo.text}</li>
        ))}
      </ul>
    </div>
  );
}

3. Creating a Sync Coordinator Route Handler

Host a central synchronization coordinator API directly inside your Next.js application:

// app/api/sync/route.ts
import { NextRequest } from 'next/server';
import { createCoordinatorHandler } from '@vaultsync/next/server';
import { InMemoryCoordinator } from '@vaultsync/node';

// Replace with a real persistent coordinator (e.g. PostgresCoordinator, RedisCoordinator)
const coordinator = new InMemoryCoordinator();

const handler = createCoordinatorHandler(coordinator, {
  validateToken: async (namespace, token) => {
    // Perform authentication/token validation here
    return token === 'secret-session-token';
  }
});

export const GET = handler.GET;
export const POST = handler.POST;

API Reference

Client-side API

<VaultSyncHydrationProvider config={config} initialData={initialData} />

Wraps the application. Populates the hydration context with pre-fetched server data, enabling client-side hooks to render it instantly while the client VaultSyncClient initializes in the background.

useHydratedData(docId)

Retrieve the raw hydrated data passed from the server for a specific document ID.

useNextQuery(docId)

Returns { data, loading }. Uses the hydrated server data on initial load, then registers a real-time reactive subscriber once the database finishes initializing.


Server-side API (@vaultsync/next/server)

queryServerDatabase(dbPath, namespace, docId)

Queries a local SQLite database directly on the server. Shuts down the client connection safely when done. Ideal for Server Components and Server Actions.

createCoordinatorHandler(coordinator, options?)

Creates a standard Next.js route handler for both GET and POST methods that handles HTTP polling sync requests (push, pull, register, heartbeat).


License

Apache 2.0 © VaultSync Authors