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

@supapower/react

v0.1.0

Published

React hooks for Supapower: PGlite live queries plus sync status

Readme

@supapower/react

React hooks for Supapower: every hook from @electric-sql/pglite-react, a ready-made extensions object covering both PGlite extensions a Supapower app needs, and useSupapowerStatus() - a PowerSync-like sync status that re-renders your component as it changes.

Installation

npm install @supapower/react supapower @electric-sql/pglite @supabase/supabase-js react

supapower, @electric-sql/pglite and react are peer dependencies - install them alongside this package. Do not install @electric-sql/pglite-react yourself: this package re-exports all of it, and a second copy in your dependency tree means a second React context, so PGliteProvider from one copy and useLiveQuery from the other would not see each other.

(of course, you can use the package manager of your choice, e.g. bun or pnpm)

Usage

1. Set up PGlite with both extensions

Supapower needs the supapower extension for syncing and the live extension for live queries. @supapower/react exports both as one extensions object:

// ./pglite.ts
import { PGlite } from '@electric-sql/pglite';
import { extensions } from '@supapower/react';

export const pg = await PGlite.create({ extensions });

In a browser with the multi-tab worker setup, both extensions go on the client side PGliteWorker.create call, not inside the worker's init() - PGliteWorker strips extensions before forwarding options to the worker:

// ./pglite.ts
import { PGliteWorker } from '@electric-sql/pglite/worker';
import { extensions } from '@supapower/react';

export const pg = await PGliteWorker.create(
  new Worker(new URL('./pglite-worker.ts', import.meta.url), { type: 'module' }),
  { extensions },
);

Need another extension too? Spread it in: extensions: { ...extensions, vector }.

2. Start the sync

import { pg } from './pglite.js';
import { supabase } from './supabase.js';

const sync = await pg.supapower.sync({ supabase, tables: ['todos'] });

See the core README for table configuration, error handling and multi-tab behavior.

3. Wrap your app and query

import { PGliteProvider, useLiveQuery } from '@supapower/react';
import { pg } from './pglite.js';

function Todos() {
  const results = useLiveQuery.sql`SELECT * FROM todos ORDER BY created_at ASC`;

  return (
    <ul>
      {results?.rows.map((todo) => (
        <li key={todo.id}>{todo.title}</li>
      ))}
    </ul>
  );
}

export function App() {
  return (
    <PGliteProvider db={pg}>
      <Todos />
    </PGliteProvider>
  );
}

useLiveQuery, useLiveIncrementalQuery, usePGlite, PGliteProvider and makePGliteProvider are re-exported from @electric-sql/pglite-react unchanged - see its docs for the full API.

4. Show the sync status

import { useSupapowerStatus } from '@supapower/react';

function SyncBadge() {
  const { connected, connecting, hasSynced, downloadError, uploadError } = useSupapowerStatus();
  const error = downloadError ?? uploadError;

  return (
    <span style={{ color: connected ? 'green' : 'orange' }}>
      {connected ? 'connected' : connecting ? 'connecting…' : hasSynced ? 'idle' : 'starting…'}
      {error ? ` · ${error.message}` : null}
    </span>
  );
}

| Field | Type | Meaning | | --------------- | ----------------------------- | --------------------------------------------------------------------- | | leading | boolean | This tab or process is the one running the sync | | connected | boolean | The realtime channel is subscribed and delivering changes | | connecting | boolean | Leading and syncing, but not connected yet | | downloading | boolean | A download (initial or catch-up) is in progress | | uploading | boolean | A batch of local changes is uploading | | hasSynced | boolean | At least one full download has finished since sync() was called | | lastSyncedAt | Date \| undefined | When the last full download finished | | downloadError | SupapowerError \| undefined | The last download-side failure, cleared by the next finished download | | uploadError | SupapowerError \| undefined | The last upload-side failure, cleared by the next finished upload |

useSupapowerStatus() works no matter when your component mounts relative to sync() - it reads pg.supapower.status and subscribes to pg.supapower.events's statusChange, so a component that mounts after the sync already started still gets the current snapshot on its first render.

Each tab's status is entirely local: only the leader tab downloads, uploads and holds the realtime channel, so every field - hasSynced included - stays false on a follower tab, even though its data keeps arriving through the shared database. Read leading before trusting the rest of the status. See Multi-tab behavior in the core README.

Exports

Everything from @electric-sql/pglite-react (useLiveQuery, useLiveIncrementalQuery, makePGliteProvider), plus:

| Export | What | | ---------------------------- | ----------------------------------------------------------------------------- | | extensions | { live, supapower }, ready to pass to PGlite.create/PGliteWorker.create | | PGliteProvider | pglite-react's PGliteProvider, typed for a database with both extensions | | usePGlite | pglite-react's usePGlite, typed for a database with both extensions | | useSupapowerStatus(db?) | The sync status hook described above | | PGliteWithLiveAndSupapower | Type: a PGlite instance carrying both extensions | | SupapowerStatus | Type: the shape useSupapowerStatus() returns |

License

Apache-2.0