RefirebaseRefirebase

onValue

Subscribe to real-time value changes at the given path.

Usage

Fires immediately with the current value, then on every change.

Example
import { db } from 'refirebase';

const unsubscribe = await db.realtime.onValue('users/123', (data) => {
  console.log('User data:', data);
});

// Later, to stop listening:
unsubscribe();

Parameters

ParamTypeDescription
path*stringThe path to the data in the database.
callback*(data: T | null) => voidFunction called immediately and whenever the data changes.

Return value

Returns

Promise<() => void>

A promise that resolves to an unsubscribe function.