Skip to main content

rivium_sync 0.2.8 copy "rivium_sync: ^0.2.8" to clipboard
rivium_sync: ^0.2.8 copied to clipboard

Realtime database plugin for Flutter - Firebase alternative with instant data synchronization across all connected devices

RiviumSync Flutter SDK #

Realtime database SDK for Flutter with offline-first sync.

pub.dev Flutter 3.3+ License: MIT

Installation #

dependencies:
  rivium_sync: ^0.2.8

Then run:

flutter pub get

Usage #

Databases and collections are addressed by their name, exactly as shown in Rivium Console:

await RiviumSync.init(RiviumSyncConfig(apiKey: 'YOUR_API_KEY'));
await RiviumSync.connect();

final todos = RiviumSync.database('my-app').collection('todos');

await todos.add({'title': 'Buy milk', 'completed': false});

final listener = todos.listen((documents) {
  print('Todos updated: ${documents.length}');
});

Use names, not UUIDs. Realtime updates are published per database and collection name, so a UUID still works for plain reads and writes but live updates never arrive.

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(RiviumSyncConfig(
  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.

Documentation #

License #

MIT

1
likes
150
points
609
downloads

Documentation

API reference

Publisher

verified publisherrivium.co

Weekly Downloads

Realtime database plugin for Flutter - Firebase alternative with instant data synchronization across all connected devices

Homepage

License

MIT (license)

Dependencies

flutter

More

Packages that depend on rivium_sync

Packages that implement rivium_sync