firebase-realtime-io
v1.1.1
Published
Socket.IO-like realtime events for Firebase
Maintainers
Readme
firebase-realtime-io
Now supports TypeScript and CJS both now with ESM!
A tiny wrapper that turns Firebase Realtime Database into a simple Socket.IO-like real-time messaging API. It uses Firebase events (onChildAdded, push, set) internally.
Note: This package is not made by Firebase and is not an official Firebase product.
LICENSE (MIT)
MIT License
Copyright (c) 2025 Izhan
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Installation
npm install firebase-realtime-io firebaseor with yarn
yarn add firebase-realtime-io firebaseUsage
1. Import Firebase and firebase-realtime-io
import { initializeApp } from "firebase/app";
import { createFirebaseIO } from "firebase-realtime-io"; // This requires firebase2. Initialize Firebase
const app = initializeApp({
apiKey: "YOUR_API_KEY",
authDomain: "YOUR_AUTH_DOMAIN",
databaseURL: "YOUR_DATABASE_URL",
projectId: "YOUR_PROJECT_ID",
storageBucket: "YOUR_BUCKET",
messagingSenderId: "YOUR_SENDER_ID",
appId: "YOUR_APP_ID"
});3. Create the realtime IO instance
const io = await createFirebaseIO({ app });- Example: Send a message
io.emit("chat", { text: "hello world" });- Example: Receive messages
io.on("chat", (data) => {
console.log("Received:", data);
});
