
Research
Security News
The Landscape of Malicious Open Source Packages: 2025 Mid‑Year Threat Report
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
rtlayer-client
Advanced tools
Make your app fun to use by adding realtime features in just few lines of code and you don't event have to handle any extra infrastructure.
rtlayer-client
is a frontend JavaScript library that makes it easy to integrate real-time messaging into your web applications. With its lightweight and efficient API, this library enables you to subscribe to real-time events, listen for updates, and manage event listeners seamlessly.
This documentation will guide you through installation, initialization, and demonstrate how to listen for and manage real-time events.
To install the rtlayer-client
package, use npm or yarn:
npm install rtlayer-client
# or
yarn add rtlayer-client
To use the rtlayer-client
library, you need to initialize an instance of the RTLayer
class with your Organization ID (oid
) and Service ID (sid
). These credentials are available in your RTLayer account.
import RTLayer from 'rtlayer-client';
const oid = "lyvSfW7uPPolwax0BHMC"; // Replace with your Organization ID
const sid = "scz8W6qP7flVprZE6vRD"; // Replace with your Service ID
const rtlayer = RTLayer(oid, sid);
export default rtlayer;
Note: The "use client"
directive is required when using React Server Components to ensure the library operates on the client side.
The on
method allows you to subscribe to events. You can listen for specific events by their name or use the wildcard (*
) to listen to all events.
import rtlayer from '@/lib/rtlayer';
rtlayer.on("*", (message) => {
console.log("Received event:", message);
});
import rtlayer from '@/lib/rtlayer';
const newsListener = rtlayer.on("news", (message) => {
console.log("News event received:", message);
});
Here’s a complete example demonstrating initialization, subscribing to events, and removing listeners:
import RTLayer from 'rtlayer-client';
// Initialize RTLayer
const oid = "lyvSfW7uPPolwax0BHMC"; // Replace with your Organization ID
const sid = "scz8WW6qP7flVprZE6vRD"; // Replace with your Service ID
const rtlayer = RTLayer(oid, sid);
// Listen for all events
rtlayer.on("*", (message) => {
console.log("Event received:", message);
});
// Listen for specific 'news' events
const newsListener = rtlayer.on("news", (message) => {
console.log("News event received:", message);
});
// Remove the listener for 'news' events
newsListener.remove();
useEffect(() => {
if (user) {
console.log(`Listening for messages for user: ${user.name}`);
// Listen for messages on a specific channel
const userChannel = `user-${user.id}`;
const listener = rtlayer.on(userChannel, (message) => {
console.log("User message received:", message);
});
// Cleanup listener on component unmount or when user changes
return () => {
console.log(`Stopping listener for user: ${user.name}`);
listener.remove();
};
}
}, [user]);
remove
method to prevent memory leaks and optimize performance."use client"
directive in React projects with mixed server and client components to ensure the library functions on the client side.The rtlayer-client
library provides a simple yet powerful way to add real-time functionality to your frontend applications. Whether you're building live notifications, chat systems, or event-driven features, this library simplifies the integration process.
Start using rtlayer-client
today to bring your applications to life with real-time capabilities!
FAQs
Make your app fun to use by adding realtime features in just few lines of code and you don't event have to handle any extra infrastructure.
We found that rtlayer-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.