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

@rivium/sync-react-native

v0.3.0

Published

React Native SDK for RiviumSync realtime database - Firebase alternative

Readme

@rivium/sync-react-native

npm version License: MIT

React Native SDK for RiviumSync - a realtime database with offline-first sync.

Installation

npm install @rivium/sync-react-native
# or
yarn add @rivium/sync-react-native

iOS Setup

cd ios && pod install

Android Setup

No additional setup required. The SDK automatically resolves from Maven Central.

Quick Start

import RiviumSync from '@rivium/sync-react-native';

// Initialize
await RiviumSync.init({
  apiKey: 'your-api-key',
});

// Connect
await RiviumSync.connect();

// Use the database and collection NAMES shown in Rivium Console (not UUIDs)
const users = RiviumSync.database('my-app').collection('users');

// Add a document
const doc = await users.add({ name: 'Alice', age: 30 });

// Listen to collection changes
const registration = users.listen((documents) => {
  console.log('Documents updated:', documents);
});
// Later: registration.remove();

Use names, not UUIDs. database() and collection() take the database and collection names as shown in Rivium Console (e.g. 'my-app', 'todos'). Names are resolved inside your API key's project. Realtime updates are published by name, so listeners only receive changes when you pass the names.

Writing documents

set() writes a document with the id you choose. The document becomes exactly the data you pass:

await users.set('alice', { name: 'Alice', age: 30 });

To change some fields and keep the others, merge instead:

await users.set('alice', { age: 31 }, { merge: true });

WriteBatch.set() takes the same { merge: true } option.

Listener errors

Your security rules decide what a listener may receive. Pass an error callback to hear why a listener stopped; after an error it receives nothing more:

import RiviumSync, { RiviumSyncError } from '@rivium/sync-react-native';

const registration = users
  .where('teamId', '==', teamId)
  .listen(
    (documents) => console.log('Team members:', documents.length),
    (error) => {
      if (error.code === RiviumSyncError.QUERY_NOT_ALLOWED) {
        // The rules do not allow this query. error.fields names the
        // filters that would make it allowed.
      } else if (error.code === RiviumSyncError.LISTENER_REVOKED) {
        // The rules no longer allow it (for example the user left the team).
      }
    }
  );

listen() and listenDocument() take the same error callback. A query's get() rejects with a RiviumSyncError with code query_not_allowed (and its fields) when the rules do not allow the query.

Verified user identity

Security Rules check auth.uid. The API key ships inside your app, so the app cannot be trusted to say who the user is - only your own server can. Have your backend mint a short-lived user token and give the SDK a way to get it:

await RiviumSync.init({
  apiKey: 'rv_live_your_api_key',
  // Return null when no one is signed in.
  tokenProvider: () => myBackend.fetchRiviumToken(),
});

// When the user signs in or out:
await RiviumSync.refreshUserToken();

The SDK asks for a token at start and again before the old one expires. It is the same Rivium user token Rivium Push and Rivium Chat use, so one function can serve all three. Your backend mints it with your project's server secret, which must stay on your server and never ship in an app.

If you would rather fetch the token yourself, call RiviumSync.setUserToken(token) after init and again whenever you refresh it.

If your project has Require signed user tokens turned on in the Console, a token is required; without it, requests are refused. You can still call connect() before anyone is signed in: the SDK waits (RiviumSync.onAwaitingUserToken) and connects by itself once it has a token.

Features

  • Real-time data synchronization
  • Offline-first with automatic sync on reconnect
  • Document CRUD operations
  • Collection and document listeners
  • Query support with filters, ordering, and pagination
  • Batch operations
  • Conflict resolution strategies

Documentation

For full documentation, visit rivium.co.

License

MIT